Back to Charts

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

Pie Chart - Labels Outer labels with leader lines. Desktop Mobile Tablet Other
Pie Chart - LabelsOuter labels with leader lines.47%35%11%7%
Pie Chart - Labels
LabelValue
Desktop1,242
Mobile918
Tablet286
Other174
<DonutChart
  title="Pie Chart - Labels"
  data={pieData}
  innerRadiusRatio={0}
  labelMode="percent"
  labelPosition="outside"
  showCenter={false}
/>

Donut center total

Donut Chart - Center Center value and legend are built into the shell. Desktop Mobile Tablet Other
Donut Chart - CenterCenter value and legend are built into the shell.2.6KVisitors
Donut Chart - Center
LabelValue
Desktop1.2K
Mobile918
Tablet286
Other174
<DonutChart
  title="Donut Chart - Center"
  data={pieData}
  centerLabel="Visitors"
/>

Active slice

Donut Chart - Active Highlight one slice with a controlled offset. Desktop Mobile Tablet Other
Donut Chart - ActiveHighlight one slice with a controlled offset.DesktopMobileTabletOther2.6KDevices
Donut Chart - Active
LabelValue
Desktop1.2K
Mobile918
Tablet286
Other174
<DonutChart
  title="Donut Chart - Active"
  data={pieData}
  activeId="Mobile"
  labelMode="label"
/>

Props

PropTypeDefaultDescription
dataDonutDatum[]Slices with label, value, optional id, and optional color.
innerRadiusRationumber0.620 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.
activeIdstringSlice id or label to offset from the center.
showCenterbooleanOverride automatic center total rendering.
centerLabelstring'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