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.
| Category | Value |
|---|---|
| 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.
| Category | Value |
|---|---|
| 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.
| Category | Value |
|---|---|
| Passed: | 128. |
| Flaky: | 14. |
| Failed: | 6. |
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly ChartDatum[] | — | Slices; non-positive values are skipped |
fill | ChartFill | solid | Slice treatment: solid, light, or gradient |
width | number | — | Controlled layout width; enables deterministic SSR |
initialWidth | number | — | SSR width hint replaced by client measurement |
height | number | 280 | SVG height in px — width is measured from the container |
innerRadius | number | 0 | Hole radius as a fraction of the outer radius (0–0.9); 0 is a pie |
paddingAngle | number | 0 | Angular gap between slices, in degrees |
startAngle | number | 0 | Where the first slice starts — degrees, 0 = 12 o'clock, clockwise |
endAngle | number | 360 | Where the last slice ends, in degrees |
showTooltip | boolean | true | Show the hover tooltip (value and share) |
showLegend | boolean | true | Show the legend when there are 2+ slices |
animate | boolean | true | Slices sweep in clockwise, staggered around the disc |
formatters | ChartFormatters | — | Format values and slice labels across tooltips, legends, and data |
label | string | — | Accessible name; defaults to the joined slice labels |
labels | ChartLabels | — | Screen-reader text of the data table and the legend, for translation |
showLabel | boolean | false | Render label as a visible title above the plot |
sx | StyleXStyles | — | StyleX style override |
ChartDatum
| Field | Type | Description |
|---|---|---|
id | string | Stable data identity |
label | string | Legend / tooltip label, falls back to id |
colorIndex | number | Palette slot 0–7; defaults to input order |
value | number | Slice magnitude; must be finite and positive to render |
Accessibility
labelprovides the concise image name.descriptionadds a richer summary througharia-describedby; consumer-owned text or a visible table can be linked with thearia-describedbyprop.- Up to 20 rendered slices receive a visually hidden native data table.
accessibleDatareplaces that table with custom React content; passnullto suppress it.labelstranslates 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.