PieChart

A part-to-whole pie or donut chart.

Import

import { PieChart } from '@matix/charts/pie-chart';

Usage

Pie and donut charts default to solid. Use fill="light" for a quieter palette or fill="gradient" for subtle depth.

Data for Organic, Paid, Referral
CategoryValue
Organic:4,200.
Paid:2,100.
Referral:700.

Donut

Set innerRadius (a fraction of the outer radius, 0–0.9) to open a hole in the middle. A little paddingAngle separates the segments.

Data for iOS, Android, Web
CategoryValue
iOS:55.
Android:38.
Web:7.

Partial sweep

startAngle and endAngle (degrees, 0 at 12 o'clock, clockwise) carve the disc into a partial ring — a half-donut summary, for example.

Data for Passed, Flaky, Failed
CategoryValue
Passed:128.
Flaky:14.
Failed:6.

API Reference

PropTypeDefaultDescription
datareadonly ChartDatum[]—Slices; non-positive values are skipped
fillChartFillsolidSlice treatment: solid, light, or gradient
widthnumber—Controlled layout width; enables deterministic SSR
initialWidthnumber—SSR width hint replaced by client measurement
heightnumber280SVG height in px — width is measured from the container
innerRadiusnumber0Hole radius as a fraction of the outer radius (0–0.9); 0 is a pie
paddingAnglenumber0Angular gap between slices, in degrees
startAnglenumber0Where the first slice starts — degrees, 0 = 12 o'clock, clockwise
endAnglenumber360Where the last slice ends, in degrees
showTooltipbooleantrueShow the hover tooltip (value and share)
showLegendbooleantrueShow the legend when there are 2+ slices
animatebooleantrueSlices sweep in clockwise, staggered around the disc
formattersChartFormatters—Format values and slice labels across tooltips, legends, and data
labelstring—Accessible name; defaults to the joined slice labels
labelsChartLabels—Screen-reader text of the data table and the legend, for translation
showLabelbooleanfalseRender label as a visible title above the plot
sxStyleXStyles—StyleX style override

ChartDatum

FieldTypeDescription
idstringStable data identity
labelstringLegend / tooltip label, falls back to id
colorIndexnumberPalette slot 0–7; defaults to input order
valuenumberSlice magnitude; must be finite and positive to render

Accessibility

  • label provides the concise image name. description adds a richer summary through aria-describedby; consumer-owned text or a visible table can be linked with the aria-describedby prop.
  • Up to 20 rendered slices receive a visually hidden native data table. accessibleData replaces that table with custom React content; pass null to suppress it. labels translates the table text and the legend name.
  • Slice marks remain aria-hidden; the chart is one image target and the table carries slice values.
  • The pointer tooltip is supplemental; the table carries values for assistive technology.
  • The legend pairs every palette swatch with a text label; it does not claim a second visual encoding beyond color.

Server rendering

Pass width for deterministic server-rendered SVG. Use initialWidth for responsive hydration from a server estimate. Without either prop, the wrapper reserves height before client measurement.