Skip to content
nexubDesign System
v11.9.0

Components · Data Display

Donut Chart

BetaAdded v3.2.0

Parts of a whole, with an optional total in the hole. Keep it to six slices or fewer.

import { DonutChart } from '@nexub/react';
View as Markdown

Playground

Props

size
Customers by plan
Pro54045%
Team31026%
Starter22018%
Free13011%
TSX
<DonutChart data={plans} center={…} title="Customers by plan" />

Examples

With total

Customers by plan
Pro54045%
Team31026%
Starter22018%
Free13011%
Plans
Enterprise4242%
Team3131%
Starter1515%
Other1212%
Show as table
Plans
LabelValueShare
Enterprise4242%
Team3131%
Starter1515%
Other1212%

States

  • Customers by plan
    Pro54045%
    Team31026%
    Starter22018%
    Free13011%
    default
  • loading
  • Customers by plan
    Pro54045%
    Team31026%
    Starter22018%
    Free13011%
    size="sm"
  • Customers by plan
    Pro54045%
    Team31026%
    Starter22018%
    Free13011%
    size="md"
  • Customers by plan
    Pro54045%
    Team31026%
    Starter22018%
    Free13011%
    size="lg"

Props

Props
PropTypeDefaultDescription
titlerequiredstring—Accessible name of the chart.
datarequiredDonutDatum[]—One entry per slice.
centerReact.ReactNode—Content in the hole, such as the total.
valueFormat((value: number) => string)defaultFormatFormats the hover text and the data table.
legendbooleantrueShow the legend beside the donut.
maxSlicesnumber—11.3: group the smallest slices into one "Other".
otherLabelstring'Other'11.3: group the smallest slices into one "Other".
legendValuesbooleanfalse11.3: value and share on each legend row.
data[].hrefstring—11.3: makes the slice's legend row a link.
data[].color1–8 | 'good' | 'warning' | 'danger' | 'neutral'—11.3: a palette colour or a tone.
size'sm' | 'md' | 'lg''md'11.3: diameter.
tableViewstring | boolean—11.3: a visible "Show as table" disclosure.
emptyStateReact.ReactNode—Shown when there is no data. Defaults to the "no data" message.
errorStateReact.ReactNode—Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty.
interactiveboolean—A crosshair and tooltip that follow the pointer, and arrow-key navigation between points.
loadingboolean—Shows a skeleton in place of the data and sets aria-busy.
onPointClick((point: ChartPoint<DonutDatum>) => void)—Click, tap, or Enter/Space on a point. Turns interactive on unless it is set to false.

Accessibility

Screen reader

  • The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value.

  • Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other".

On iOS & Android