PieChart
Compare series and read the change behind them, with the axes, legend and tooltip already wired.
@luc/ui/chartsWhat it shows
Show the parts of one whole when the categories are few and the shares are meaningfully different.
Live preview
Five parts of a genuine whole, capped at six by the component itself.
<PieChart
data={[
{ name: "Equity", value: 42 },
{ name: "Credit", value: 24 },
{ name: "Rates", value: 16 },
{ name: "Gold", value: 11 },
{ name: "Cash", value: 7 },
]}
centerValue="100"
centerLabel="Weight"
format={{ kind: "percent", decimals: 0 }}
height={320}
ariaLabel="Portfolio weights"
/>Controls
Height
A chart measures its container, so it always needs a definite height.
State
The surface the chart is in — loading, empty and error are drawn by the component.
Accessible name
A drawing is not readable by a screen reader, so it needs a name that states what it shows.
The same fixture as the live preview above; the controls change how it is drawn, not what it measures.
Code
import { PieChart } from "@luc/ui/charts";
<PieChart
data={[
{ name: "Equity", value: 42 },
{ name: "Credit", value: 24 },
{ name: "Rates", value: 16 },
{ name: "Gold", value: 11 },
{ name: "Cash", value: 7 },
]}
centerValue="100"
centerLabel="Weight"
format={{ kind: "percent", decimals: 0 }}
height={320}
ariaLabel="Portfolio weights"
state="ready"
/>Not controllable here
series / rows— The numbers are the caller's; the fixture above is the example.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `PieChart` from Luc UI. It is: Compare series and read the change behind them, with the axes, legend and tooltip already wired.
Import it with: import { PieChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.
Chosen configuration: `height={320}`, `state="ready"`, `ariaLabel="Portfolio weights"`.
Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.
Reproduce this state:
```tsx
<PieChart
data={[
{ name: "Equity", value: 42 },
{ name: "Credit", value: 24 },
{ name: "Rates", value: 16 },
{ name: "Gold", value: 11 },
{ name: "Cash", value: 7 },
]}
centerValue="100"
centerLabel="Weight"
format={{ kind: "percent", decimals: 0 }}
height={320}
ariaLabel="Portfolio weights"
state="ready"
/>
```Usage
The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.
It is drawn by the ECharts engine.
Worked examples with real data are on the family overview: General
import { PieChart } from "@luc/ui/charts";<PieChart
data={[
{ name: "Equity", value: 42 },
{ name: "Credit", value: 24 },
{ name: "Rates", value: 16 },
{ name: "Gold", value: 11 },
{ name: "Cash", value: 7 },
]}
centerValue="100"
centerLabel="Weight"
format={{ kind: "percent", decimals: 0 }}
height={320}
ariaLabel="Portfolio weights"
/>Data contract
`data` is an ordered array of `{ name, value }` rows for one series. Values must be comparable parts of the same whole; the component caps the display at six slices.
Important configuration
Set `format` to the share's actual unit, and use `centerValue`/`centerLabel` only for a real total or summary rather than decoration.
Guidelines
When not to use
Do not use a pie or donut to compare many close categories; a sorted bar chart gives lengths that are easier to compare.
Configuration
| Export | Kind | Signature |
|---|---|---|
PieChart | 14 documented props | ({ data, variant, format, centerLabel, centerValue, title, description, state, height, className, ariaLabel, ariaDescription, onReady, onEvent, }: PieChartProps) => import("@types/react").JSX.Element |
PieChart props
Type: PieChartProps
Values the compiler reads from the declaration.
| Prop | Type | Default | Notes |
|---|---|---|---|
ariaDescription? | string | undefined | — | |
ariaLabel? | string | undefined | — | |
centerLabel? | string | undefined | — | Optional value printed in the middle of a donut. |
centerValue? | string | undefined | — | |
className? | string | undefined | — | |
data | readonly CategoryValue[] | — | |
description? | string | undefined | — | |
format? | ChartFormat | undefined | — | |
height? | string | number | undefined | — | |
onEvent? | ((event: EChartEvent) => void) | undefined | — | |
onReady? | ((chart: EChartsInstance) => void) | undefined | — | |
state? | ChartState | undefined | — | |
title? | string | undefined | — | |
variant? | "pie" | "donut" | undefined | — | Donut by default: a ring reads better next to a metric than a solid disc. |
Accessibility
A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.
What happens on the server, and when hydration changes it.
Family
General
The shapes every product needs, on the declarative ChartSpec path.
Related