Skip to content
misoto22 design

Charts

PieChart

Parts of one whole.

When to reach for it

Roughly what share, and nothing more precise. Ranking or comparing wedges — especially across two pies — is a BarChart’s job.

Examples

default

Visitors by browser
Visitors by browser
browserValue
chrome275
safari200
firefox187
edge173
other90

shape

Visitors by browser — donut
Visitors by browser — donut
browserValue
chrome275
safari200
firefox187
edge173

labels and emphasis

Labelled
Labelled
browserValue
chrome275
safari200
firefox187
edge173
One wedge is the point
One wedge is the point
browserValue
chrome275
safari200
firefox187
edge173

loading

Visitors by browser
Loading

Notes

Parts of one whole.

Worth saying plainly: a pie answers "roughly what share" and nothing more precise. Comparing two adjacent wedges by eye is unreliable past about five of them, and comparing a wedge across two pies is worse. When the reader needs to rank or compare, a <BarChart> answers the same question better.

Props

PieChart props
PropTypeDefaultDescription
childrenrequiredReactNodeThe composed parts — axes, grid, tooltip, legend, and the marks themselves.
configrequiredChartConfigSector names → their label and paint. Keys must match the `nameKey` values.
datarequiredTData[]The rows the chart draws. One entry per point, bar or category.
dataKeyrequiredkeyof TData & stringThe row field holding each sector's number.
nameKeyrequiredkeyof TData & stringThe row field holding each sector's name.
titlerequiredstringWhat the chart shows, in a sentence a reader could act on. Required, and announced to a screen reader even when it is not printed.
chartPropsComponentProps<typeof RechartsPieChart>Escape hatch onto the raw Recharts chart element.
classNamestringMerged onto the figure, last, so a call site can size or space it.
defaultSelectedSectorstring | nullnullThe sector lit on first render.
descriptionReactNodeA line under the title — the unit, the window, the caveat.
hideDataTablebooleanfalseDrops the hidden table view. Only correct when the page prints the data itself.
isLoadingbooleanfalseSwaps the marks for an animated skeleton, keeping the measured height so the page does not jump when the data lands.
onSelectionChange(selection: { name: string; value: number } | null) => voidFires when the selection changes, and with null when it is cleared.
showTitlebooleanPrints the title above the plot instead of hiding it from sight.

Types

TSX
export type PieVariant = 'gradient'

Accessibility

  • title is required; the rows are also rendered as a visually hidden table.
  • The legend sits under the pie by default, because a pie has no category axis naming its sectors.
  • Compose a Label to print the numbers on the wedges: a pie’s weakness is that an angle is hard to read, and a printed number removes the guess.
  • One fill variant, deliberately. A wedge is small and awkwardly shaped, and a texture inside one reads as noise.