PieChart
data: [{ label, value, color? }]. Add donut (and optionally center) for a ring. Hover a slice for its label, value and share in a tooltip that follows the mouse.
- Kevin: 62 (62%)
- Stuart: 21 (21%)
- Bob: 9 (9%)
- Others: 8 (8%)
- Kevin
- Stuart
- Bob
- Others
- Eaten: 70 (70%)
- Left: 30 (30%)
- Eaten
- Left
When the data changes the slices swing to their new size; the tooltip and legend always show the real values.
- Kevin: 36 (35%)
- Stuart: 36 (35%)
- Bob: 31 (30%)
- Kevin
- Stuart
- Bob
Props
data{ label, value, color? }[]Slices.
donutbooleanDefault:falseRender a ring.
centerReactNodeText in the donut hole.
labelstringDefault:'Pie chart'Accessible name.
animatebooleanDefault:trueAnimate the chart in when it appears and glide it to new values when the data changes (skipped for users who prefer reduced motion).
classNamestringDefault:''Extra classes for the root element.
| Prop | Type | Default | Description |
|---|---|---|---|
data | { label, value, color? }[] | – | Slices. |
donut | boolean | false | Render a ring. |
center | ReactNode | – | Text in the donut hole. |
label | string | 'Pie chart' | Accessible name. |
animate | boolean | true | Animate the chart in when it appears and glide it to new values when the data changes (skipped for users who prefer reduced motion). |
className | string | '' | Extra classes for the root element. |