Skip to content
  • System
  • Light
  • Dark
  • High contrast

DonutChart

Each datum has a label, value, and color. Children render in the centre.

Conformance summary

Donut chart, 4 points. Values from 8 to 42.

86criteria
import { DonutChart } from '@eekodigital/raster';

<DonutChart
  data={[
    { label: 'Pass', value: 42, color: 'var(--demo-good)' },
    { label: 'Fail', value: 8, color: 'var(--demo-bad)' },
    { label: 'N/A', value: 12, color: 'var(--demo-neutral)' },
    { label: 'To do', value: 24, color: 'var(--demo-warn)' },
  ]}
  title="Conformance summary"
>
  <strong>86</strong>
  <span>criteria</span>
</DonutChart>

Use smaller size and thickness for inline progress indicators.

75% complete

Donut chart, 2 points. Values from 25 to 75.

75%
<DonutChart
  data={[
    { label: 'Complete', value: 75, color: 'var(--demo-good)' },
    { label: 'Remaining', value: 25, color: 'var(--demo-muted)' },
  ]}
  size={80}
  thickness={10}
  title="75% complete"
>
  <strong>75%</strong>
</DonutChart>
  • A role="figure" named by the visible title and described by a generated summary (chart type, series and point counts, range).
  • The SVG is a role="group" with aria-roledescription="chart"; no graphics-* roles.
  • Each segment is labelled {label}: {value} ({percent}), 2 of 4. Zero-value segments are skipped. With onSelect, selectedIndex or a click handler, marks are role="button" with aria-pressed; otherwise they’re static role="img".
  • A visible Show data table button (aria-expanded) reveals a real table captioned Data for {title}, with th scope headers and values run through formatValue.
  • Escape (inside the chart only) clears the selection and announces it in a polite live region; it doesn’t close a surrounding dialog.
  • The draw-in animation is a CSS class, so prefers-reduced-motion switches it off.
  • Animations stop under prefers-reduced-motion. In forced-colours mode marks use system colours, told apart by dash pattern and marker shape.
Key Action
← → ↑ ↓ Previous / next segment (wraps)
Home / End First / last segment
Tab Leave the chart
Enter / Space Toggle selection (interactive marks)
Escape Hide the tooltip and clear selection

See the Accessibility guide for the shared structure, the labels prop and screen-reader testing.

PropTypeDefaultDescription
dataDonutDatum[]—

Required. { label, value, color }.

sizenumber—Fixed diameter in px. Omit to fill the container’s width (square).
thicknessnumber24Ring thickness in px.
childrenReactNode—Centre content.
showLegendbooleanfalseShow a legend.
formatValue(value: number) => stringIntl.NumberFormat

Formats values in ticks, marks and the table. Defaults to Intl.NumberFormat(labels.locale).

onSegmentClick(datum, index) => void—Makes segments buttons.
selectedIndexnumber | null—Controlled selection.
onSelect(index | null) => void—Makes segments buttons.
titlestring—Required. Visible title: names the figure and captions the data table.
hideTitlebooleanfalseHide the title visually. It still names the chart for assistive technology.
labelsPartial<ChartLabels>English

Generated strings and the number locale. See Accessibility.

dataTable“disclosure” | “visually-hidden”“disclosure”How the data table is offered.
exportRefRef<ChartExportHandle>—

SVG/PNG export. See Exporting charts.

classNamestring—Class on the figure.