# Donut chart

Parts of a whole, two to five, with the total in the center and exact shares; more parts fold into "Other".

- Family: charts
- Import: `import { DonutChart } from "@senvenli/react/charts";`
- Page: https://design.senvenli.com/docs/components/donut-chart
- JSON: https://design.senvenli.com/docs/components/donut-chart.json

## Example: Orders by channel

A few parts of one total, with exact shares beside the ring.

```tsx
import { DonutChart } from "@senvenli/react/charts";

const CHANNELS = [
  { name: "Website", value: 1840 },
  { name: "Mobile app", value: 1265 },
  { name: "Marketplace", value: 720 },
  { name: "Phone", value: 215 },
];

export default function Example() {
  return <DonutChart title="Orders by channel" period="March 2026" data={CHANNELS} centerLabel="orders" />;
}
```

## Examples

### More than five parts

The smallest parts fold into "Other", so the ring stays readable.

```tsx
import { DonutChart } from "@senvenli/react/charts";

const COUNTRIES = [
  { name: "United States", value: 412000 },
  { name: "Germany", value: 186000 },
  { name: "United Kingdom", value: 154000 },
  { name: "Canada", value: 98000 },
  { name: "France", value: 71000 },
  { name: "Spain", value: 43000 },
  { name: "Netherlands", value: 29000 },
];
const usd = new Intl.NumberFormat("en", { style: "currency", currency: "USD", notation: "compact" });

export default function Example() {
  return <DonutChart title="Revenue by country" period="2026" data={COUNTRIES} valueFormatter={usd.format} />;
}
```

### Ring only

Without the value list, for a narrow card.

```tsx
import { DonutChart } from "@senvenli/react/charts";

const PLANS = [
  { name: "Free", value: 5200 },
  { name: "Team", value: 1900 },
  { name: "Enterprise", value: 340 },
];

export default function Example() {
  return <DonutChart title="Customers by plan" data={PLANS} centerLabel="customers" showList={false} height={200} />;
}
```

## Guidelines

### When to use it

- Shares of one total, at most five parts.

### Use something else when

- [bar-list](https://design.senvenli.com/docs/components/bar-list.md): There are many parts or they are compared, not summed.

## Accessibility

Built in:

- A "Show as table" button shows the same data as a table, which screen readers get by default.

You provide:

- A title that says what the figure is.

## API reference

### DonutChart

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| title | `string` |  | no | What the chart shows, over it; leave it out when a card or a heading already says so. |
| aria-label | `string` |  | no | Names the chart when it has no visible `title` (a card's heading already says what it shows). |
| period | `string` |  | no |  |
| isLoading | `boolean` |  | no |  |
| emptyState | `React.ReactNode` |  | no | Shown instead of the plot when there is no data: an `EmptyState size="small"` or text; "No data" by default. |
| height | `number` | `200` | no |  |
| data | `readonly DonutDatum[]` |  | yes | Two to five parts; more are folded into "Other". |
| valueFormatter | `ChartValueFormatter` | `plain` | no |  |
| centerLabel | `string` |  | no | Under the total in the center: its unit ("orders"). |
| showList | `boolean` | `true` | no | The value list beside the ring with exact percentages; on by default. |

### Tokens it reads

`--ds-background-neutral`, `--ds-background-neutral-pressed`, `--ds-border`, `--ds-border-bold`, `--ds-border-focused`, `--ds-chart-1`, `--ds-chart-2`, `--ds-chart-3`, `--ds-chart-4`, `--ds-chart-5`, `--ds-chart-neutral`, `--ds-link`, `--ds-radius-medium`, `--ds-radius-small`, `--ds-radius-xsmall`, `--ds-shadow-overlay`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-space-300`, `--ds-space-400`, `--ds-surface-overlay`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-success`

## Related

- [bar-list](https://design.senvenli.com/docs/components/bar-list.md)
