Circular
DonutChart
Pie and donut composition powered by D3 pie and arc generators, with labels, active slices, legends, center totals, and tooltip rows.
Examples
Pie with outside labels
| Label | Value |
|---|---|
| Desktop | 1,242 |
| Mobile | 918 |
| Tablet | 286 |
| Other | 174 |
<DonutChart
title="Pie Chart - Labels"
data={pieData}
innerRadiusRatio={0}
labelMode="percent"
labelPosition="outside"
showCenter={false}
/>Donut center total
| Label | Value |
|---|---|
| Desktop | 1.2K |
| Mobile | 918 |
| Tablet | 286 |
| Other | 174 |
<DonutChart
title="Donut Chart - Center"
data={pieData}
centerLabel="Visitors"
/>Active slice
| Label | Value |
|---|---|
| Desktop | 1.2K |
| Mobile | 918 |
| Tablet | 286 |
| Other | 174 |
<DonutChart
title="Donut Chart - Active"
data={pieData}
activeId="Mobile"
labelMode="label"
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | DonutDatum[] | — | Slices with label, value, optional id, and optional color. |
innerRadiusRatio | number | 0.62 | 0 renders a pie; larger values render a donut. |
labelMode | 'none' | 'label' | 'value' | 'percent' | 'none' | Controls labels rendered inside or outside slices. |
labelPosition | 'inside' | 'outside' | 'inside' | Position for slice labels. |
activeId | string | — | Slice id or label to offset from the center. |
showCenter | boolean | — | Override automatic center total rendering. |
centerLabel | string | 'Total' | Small label rendered under the center total. |
Install
CLI
npm install d3-shape
npx @a3tai/mittsu add donut-chart --registry ./packages/charts/registry.json