Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Radial Chart

PreviousNext

Progress of a few values against their target as concentric rings, round a full circle or a half gauge.

Quarterly goals
Acme Inc, Q4 so far
Quarterly goals
ValueMaxShare
Revenue412K500K82.4%
New customers28432088.8%
Renewals16818093.3%

Give it rows of data with a name, a value and a target. Each row is a ring, the first outermost: a faint track for the whole target and an arc over it, in the next colour of the chart palette, as far round as the value goes. Arcs have round caps and the rings keep a gap between them. The centre shows the first ring's share, or your own centerLabel.

Point at a ring, tap it or tab to the chart and use the arrow keys: the other rings fade back and a tooltip gives its share, value and target. The arcs sweep from zero the first time the chart is on screen, and turn to their new length when the data changes.

Radial Chart is part of the Fabricator style. It's drawn in SVG, so the same component ships for every base, and its layout comes from the same model as the React Native version.

Installation

bunx --bun fabricator-ui@latest add radial-chart

Usage

import { RadialChart } from "@/components/ui/radial-chart"
const data = [
  { goal: "Revenue", value: 412_000, target: 500_000 },
  { goal: "New customers", value: 284, target: 320 },
]
 
<RadialChart
  data={data}
  nameKey="goal"
  maxKey="target"
  label="Quarterly goals"
/>

nameKey and valueKey name the fields to read, and default to name and value. Measure every ring against one target with max, or each against its own with maxKey; with neither, the largest value is the target. A value past its target fills the ring, and the tooltip still gives its real share. A row without a value has no ring. config is optional: keyed by a ring's name, it gives that ring a label and a color.

Examples

Half gauge

shape="half" turns the rings into a gauge from 9 to 3 o'clock, about twice as wide as it is tall, with the centre figure under the arcs.

Plan usage
ValueMaxShare
API calls7.4K10K74.2%
Seats182572%

Colours

Rings take the chart palette in the order of the data. Give one its own with config[name].color: a palette slot, an upstream chart token (chart-1 … chart-5), a role (primary, info, success, …), a CSS variable (var(--brand)) or any CSS colour. Status roles mean status: use success or warning only where the ring's colour should say whether a target is met.

TokenHueTokenHue
--chart-series-1blue--chart-series-5magenta
--chart-series-2orange--chart-series-6green
--chart-series-3aqua--chart-series-7violet
--chart-series-4amber--chart-series-8red

Tracks are a faint neutral, so the arcs carry the colour. The centre figure stays in the text colour.

Motion

  • Sweep: the first time the chart scrolls into view, the arcs sweep from zero to their value on the reveal role in a short wave from the outer ring in, once per mount.
  • Morph: when data, config, the targets, shape or the visible rings change, each arc turns to its new length and each ring moves to its new place on the move role. A new ring grows in; one being hidden shrinks away.
  • Spotlight: the other rings fade back on the feedback role while one is inspected.

All follow the motion speed of the region they sit in. Reduce Motion and the instant speed draw the chart at once and keep only the fades; animate={false} does the same for one chart.

API Reference

RadialChart

All other props go to the root <div>.

PropTypeDefault
dataTDatum[]required
labelstringrequired: the accessible name
nameKeykeyof TDatum"name"
valueKeykeyof TDatum"value"
maxnumberthe largest value
maxKeykeyof TDatum-
shape"full" | "half""full"
centerLabelstringthe first ring's share
configChartConfig, keyed by ring namenames and the palette
formatValue(value: number, key: string) => string1,234
legendbooleanon for two or more rings
tooltipbooleantrue
animatebooleantrue
loadingbooleanfalse
emptyReactNode"No data"
onActiveChange(active: ChartActive<TDatum> | null) => void-

formatValue receives valueKey as its key, for values and targets alike. onActiveChange reports the inspected ring's row, with its name as key.

Data attributes

AttributeElementPresent when
data-slot="radial-chart"rootalways
data-loadingrootloading is true
data-slot="chart-plot"the plotalways; data-shape is the shape
data-slot="radial-chart-ring"a ringalways; data-active when inspected, data-dimmed when not
data-slot="radial-chart-track"its trackalways
data-slot="radial-chart-value"its arcalways
data-slot="radial-chart-center"the centrethere is data
data-slot="chart-legend"the legendthe legend shows
data-slot="chart-tooltip"the tooltipa ring is inspected

Accessibility

  • The plot is a slider named after label ("Quarterly goals: inspect values"). Tab to it, then the arrow keys step through the rings from the outside in, Home and End jump to the first and last, and Escape lets go. Its value text reads the ring's name, value, target and share.
  • Every row is also in a table hidden from sight, with its value, target and share.
  • With two or more rings the legend shows, so no ring is told apart by colour alone. Its items are toggle buttons with aria-pressed.
  • Text never takes a ring's colour: the centre and the tooltip stay in the text colours.
  • loading sets aria-busy on the root and dims the last drawing until new data arrives.