PieChart
PieChart, PieChartProps: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Pie Chart#
Generic over TDatum extends Chart; the props below name it.
Props
- Type
string
Category/label field name. Drives tooltip/legend/label text.
- Type
TDatum[]
Flat array of row objects. Each row is one slice/segment/spoke.
- Type
number
Container height in pixels. Width is always responsive.
- Type
string
Numeric value field name. Drives slice/segment size.
- Type
boolean | LegendOptions
Enable legend.
- Type
StandaloneAccessibility Options
Accessible name, description, data table and keyboard navigation. No announcements: it switches <Chart>'s interaction announcements, which this family does not make.
- Type
StandaloneAnimation Option
The entrance: one scale-and-fade, 400 ms by default; false turns it off. There is no other entrance type and no series to stagger.
- Type
string
Label displayed in the center of a donut chart (e.g. total value).
- Type
string
Secondary text below the center label.
- Type
string
Optional className applied to the outer container.
- Type
string[]
Categorical palette for this chart only: replaces the host palette (--chart- … --chart-) in the chart's colour assignment, and nothing else. It is a data encoding, not a theme: surfaces, text, grid and semantic roles keep coming from the CSS token contract, and a series, datum or annotation that sets its own colour keeps it. Any CSS colour string (a public token reference such as var(--chart-, hex, oklch).
- Type
boolean | PieCallout Label Options
The callout labels: outside the slices, with leaders, in two columns. Each shows the name and the value (with the share, unless percentage is false); name and value switch their part (CF1), and min leaves narrow slices without one. The pie radius shrinks to make room; crowded labels get ellipsis or are dropped starting from the smallest slices. Boolean shorthand: true = enabled with defaults. Default: false.
- Type
readonly ChartItem Ref[]
The initial selection of an uncontrolled chart.
- Type
"ltr""rtl"
The chart's UI direction: the reading direction of its HTML text and chrome (tooltip, legend, menus, the accessible table), and the direction the context menu carries under <body>.
Left out, the chart inherits the direction of the page around it (the nearest dir attribute, else the computed CSS direction) and follows a later change of that attribute. It is never inferred from locale, and it never reverses an axis or reorders data: reversed stays an explicit axis choice. Under rtl the chrome mirrors (legend flow, tooltip side, context menu and submenus, report text in exports), a title-like label starts at the inline start, and a label placed by geometry (an axis tick, a slice or bar label) keeps its physical side; plot arrow keys stay spatial while legend and menu arrows follow the reading direction.
- Type
boolean
Display as donut (ring).
- Type
(Omit<ChartEvents, "on Zoom Change"…
The chart's events, and the selection events (T8): a slice is an item of the chart's one series (series 'pie'), keyed by its category value unless selection. names another field.
- Type
number
Inner radius for donut mode.
- Type
ChartLegend Link
Connects the chart's legend to use, for a legend the host renders itself. Give one link to one chart.
- Type
ValuePresentation
Presentation input for axis labels, tooltips, labels and accessibility announcements: a locale code (notation follows the language), or a presentation-context object ({language) carrying language and notation independently. date is the normal human date shape a plain date consumer inherits; an axis that declares its own preset for readability keeps it. Forwarded untouched to the central @workspace/; the package never resolves tenant or application settings itself. When omitted, <Chart supplies it; with neither, the chart throws a configuration error (no 'en' fallback, active-format D14). Object inputs must be referentially stable across renders.
- Type
string
The chart's name: its accessible name and <title> (LAB-AT21).
- Type
number
The gap between slices, in degrees. Default: about 0.573° (0.01 rad, the default drawing unchanged by T2-D5).
- Type
DatumPaint Resolver<…>
A slice's own fill, by a rule over its row: the one fund in the accent colour, the slices below a threshold in the negative role. Returns {fill} or undefined for the slice's palette colour; paint only. The slice IS its legend category, so its legend key, its tooltip swatch, its sector label's contrast surface and its export all show the painted fill; forced colours override it. The context's series is 'pie' and its series the chart's name. See Datum.
- Type
Ref<ChartExport Handle>
Imperative handle: exports and element access. A family built on this type has no data-range zoom, so its handle has no set. Allows getting a ref to the component instance. Once the component unmounts, React will set ref. to null (or call the ref with null if you passed a callback ref).
- Type
boolean | PieSector Label Options
The sector labels: one line inside each slice (CF1), by default its share of the visible total. A sector label shows only where it fits in its slice and reads on the slice's colour; it never moves outside. Independent of data: both may show at once. Boolean shorthand: true = the share. Default: false.
- Type
readonly ChartItem Ref[]
The selection, controlled by the host. The chart draws, announces and lists the items it resolves to and never changes it; the host updates it from on. A request the host applies is announced when the host passes it back; one it ignores is never announced. A reference to an item that is hidden, zoomed or drilled out of view, or not in the data stays in the host's selection and is not shown as selected.
- Type
number
Where the first slice starts: degrees clockwise from 12 o'clock, the one radial convention (T2, ADR-095). Default: 0 (12 o'clock). Any finite number; the pie stays whole. The slices keep their data order clockwise from here, and the legend, the keyboard, the table and the announcement keep that order. An angle that is not a finite number is reported to the host's diagnostics and draws the default.
- Type
ChartTranslate Fn
The host translator for every text the chart shows or announces. When omitted, <Chart supplies it; with neither, the chart throws a configuration error (no English fallback, ADR-028).
- Type
StandaloneTooltip Option
Tooltip configuration: enabled, renderer, value, style. The pie has no tooltip modes, snapping or pinning.
- Type
ChartValue Semantics
What the slice values mean (BC1): unit and precision, declared once with the type the Cartesian charts read (Chart). The callout and sector values, the tooltip, the data table and the announcement then write each value in it; a share of the whole stays a percentage. A role's own formatter or format (and tooltip.) still wins; without a declaration the chart presentation's number applies. CSV and Copy value keep the raw number.
- Type
number
Optional fixed width in pixels. Default: fill container.
Events
Called by the component when something happens.
- Type
(change) => void
Fired once for every legend change the chart applies: a hide, a show, an isolation or a show-all, from the built-in legend (click, key, double click, double tap), its menu, or use. The change names the entry and its target by identity and lists every hidden target after it. A refused action (the last visible target, legend.) changes nothing and reports nothing.
- Type
(selection, change) => void
Fired when the reader changes the selection (pointer, touch or keyboard), and when an uncontrolled selection drops items the data no longer contains. selection is the complete selection the change makes; it keeps every reference the selection held, of whatever form. On a controlled chart it is a proposal (change.), computed from the current selected and never from an earlier proposal; the host applies it, changes it or ignores it.
- Type
(event) => void
Fired when a chart animation completes.
'load': initial mount animation finished (or immediately if animation disabled / prefers-reduced-motion is active).'update': data-update transition finished.
Not triggered by zoom animations (use on) or tooltip fades.
- Type
(result) => void
Fired after a successful export action (PNG/SVG/CSV/PDF), including from the context menu and from imperative Chart calls.
- Type
(format, error) => void
Fired when an export could not produce its file (W11), from the handle as well as from the context menu. Without it a failed context-menu export is reported as an error diagnostic (<Chart).
- Type
(item, source) => void
Fired when the reader activates an item: a click or tap on it, or Enter on the focused item (Shift+Enter on a sankey, whose Enter moves between nodes and links). With a handler, Enter activates instead of opening the context menu (Shift+F10 and the context-menu key still open it).
- Type
() => void
Fired exactly once per chart instance, after the first successful mount with valid dimensions and before any entrance animation starts. "Ready" means: the SVG is in the DOM, layout has run with real dimensions, and the chart can be queried by integration tests.
Distinct from on with type: 'load', which fires *after* the load animation finishes. A chart with animation={false} still fires on — animation state has no effect on readiness.
A new React key on the host produces a new component instance and on fires again. Identity changes of the callback itself after the first fire are ignored (latch is per-instance).
Consumer requirement — stable from first render. The latch closes on the first effect run regardless of whether on was defined at that moment. If on is initially undefined and later resolves to a function, the callback will never fire — the latch has already closed with a no-op. Pass a stable reference (typically via use) or pass the final function unconditionally from the first render.
Other props, such as the standard attributes of the underlying element, className and ref, are passed through.
Types#
Props for Pie. Extends Categorical to join the wrapper contract (context-driven defaults via <Chart, unified event model, colors/accessibility propagation). Chart-specific fields (donut, inner, center, data, legend) remain on this interface.
The props of Pie, each described in its prop list on this page.
interface PieChartProps<TDatum extends ChartDatum = ChartDatum>
extends
Omit<CategoricalChartProps<TDatum>, 'tooltip' | 'animation' | 'events'>,
ChartSelectionProps<TDatum, ChartSeriesItem<TDatum>> {
events?: NonNullable<CategoricalChartProps<TDatum>['events']> &
ChartSelectionEvents<TDatum, ChartSeriesItem<TDatum>>;
tooltip?: StandaloneTooltipOption;
animation?: StandaloneAnimationOption;
donut?: boolean;
innerRadius?: number;
padAngle?: number;
startAngle?: number;
name?: string;
legend?: LegendOptions | boolean;
legendLink?: ChartLegendLink;
centerLabel?: string;
centerLabelSecondary?: string;
dataLabels?: PieCalloutLabelOptions | boolean;
sectorLabels?: PieSectorLabelOptions | boolean;
valueSemantics?: ChartValueSemantics;
paint?: DatumPaintResolver<DatumFill, TDatum>;
}