GitHubGitHub
← All widgets
Charts / widget

Donut chart

Proportional composition ring with center label, legend, and per-slice colors.

LegendCenter label
import { DonutChart } from '@chanrg/4ui/echarts';<DonutChart slices={[{ name: 'us-east-1', value: 62 }]} unit="%" centerLabel="Traffic" />

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { DonutChart } from '@chanrg/4ui';import { DonutChart } from '@chanrg/4ui/echarts';<DonutChart slices={[{ name: 'us-east-1', value: 62 }]} unit="%" centerLabel="Traffic" />

API reference

Props

PropTypeDefaultDescription
slices{ name, value, color? }[][]Ring segments.
centerLabelstringText inside the ring.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.

Accessibility

  • Legend carries the names; keep values available as text nearby.

Dependencies

echarts (optional peer — install alongside)