Skip to content
Alea0.1

Charts

PieChart and DonutChart

Parts of a whole, with the share of each slice in the legend and the total in the middle.

Ant Design: Pie (Ant Charts)

import { PieChart, DonutChart } from '@alea/ui';

Examples

Donut with total

The share of each slice is in the legend; the total sits in the middle.

Sessions by source
9,600Sessions
Same data as a pie

Small donut

A compact share with its own number in the middle.

Plan mix
68%on Pro

Props

PieChart props

Parts of a whole. Keep it to six slices or fewer; the legend shows each share (MUI PieChart, Mantine DonutChart).

PropTypeDefaultDescription
datarequired{ label: string; value: number; color?: string | undefined; }[]-Slices: label and value (and an optional color).
centerCaptionReactNode'Total'Small text under the center number of a donut. Default "Total".
centerLabelReactNode-Big text in the middle of the donut. Default the total.
classNamestring-Extra class names for the root element.
descriptionReactNode-One sentence on what the chart shows; read before it.
innerRadiusnumber0Inner radius as a share of the radius: 0 is a pie (default), around 0.6 is a donut.
showTablebooleantrueShows the "view as table" toggle. Default true.
sizenumber220Size in px. Default 220.
titleReactNode-The title shown above it and read by screen readers.
valueFormat((v: number) => string)-Formats values in the axis, tooltip and table, e.g. v => `${v}k`.

DonutChart props

A PieChart with a hole: same props.

PropTypeDefaultDescription
datarequired{ label: string; value: number; color?: string | undefined; }[]-Slices: label and value (and an optional color).
centerCaptionReactNode-Small text under the center number of a donut. Default "Total".
centerLabelReactNode-Big text in the middle of the donut. Default the total.
classNamestring-Extra class names for the root element.
descriptionReactNode-One sentence on what the chart shows; read before it.
innerRadiusnumber-Inner radius as a share of the radius: 0 is a pie (default), around 0.6 is a donut.
showTableboolean-Shows the "view as table" toggle. Default true.
sizenumber-Size in px. Default 220.
titleReactNode-The title shown above it and read by screen readers.
valueFormat((v: number) => string)-Formats values in the axis, tooltip and table, e.g. v => `${v}k`.

Accessibility

  • Named with every slice and its share.

Keyboard

KeyDoes
TabFocuses the chart
Arrow keysRead each slice
EscapeHides the tooltip

Do and don't

Do

  • Six slices or fewer; group the rest as Other.
Tested with axe, keyboard and screen reader roles