Several measures of one or more subjects on shared axes, as polygons over a hairline grid.
| Acme Inc | Industry average | |
|---|---|---|
| Performance | 86 | 70 |
| Reliability | 92 | 75 |
| Usability | 78 | 72 |
| Support | 88 | 66 |
| Price | 64 | 70 |
| Integrations | 72 | 68 |
Give it rows of data, the field that names each axis (index) and a config that names the series to draw. Each row is an axis, clockwise from 12 o'clock; each series is a polygon through its value on every axis, with a faint wash of its colour from the chart palette and a 2px outline. Every axis shares one scale from zero at the centre, drawn as four hairline polygons and the spokes, with the axis names just outside.
Point at the chart, drag a finger round it or tab to it and use the arrow keys: the nearest axis' spoke lights up, each series shows a ringed dot on it and a tooltip lists every series' value there. The legend hides a series when pressed and spotlights it when pointed at. The polygons grow from the centre the first time the chart is on screen, and move vertex by vertex when the data changes.
Radar 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 radar-chart
Usage#
import { type ChartConfig } from "@/components/ui/chart-kit"
import { RadarChart } from "@/components/ui/radar-chart"const data = [
{ measure: "Performance", acme: 86, average: 70 },
{ measure: "Reliability", acme: 92, average: 75 },
{ measure: "Usability", acme: 78, average: 72 },
]
const config = {
acme: { label: "Acme Inc" },
average: { label: "Industry average" },
} satisfies ChartConfig
<RadarChart data={data} index="measure" config={config} label="Customer scorecard" />Each key of config is a field of the rows. A missing value draws its vertex at the centre and reads "–" in the tooltip; negative values sit at the centre too. The scale runs from zero to a clean number at or above the largest value. The chart fills its container's width and is 20rem tall until you give it a height with className; the radar shrinks until every axis name fits.
Examples#
One series#
A single series needs no legend: label already names what is plotted.
| Design team | |
|---|---|
| Research | 70 |
| Interface | 92 |
| Prototyping | 85 |
| Writing | 60 |
| Accessibility | 78 |
Several series#
Washes stay faint so the outlines read where polygons overlap. Point at a name in the legend to spotlight its series, or press it to hide it.
| Starter | Pro | Enterprise | |
|---|---|---|---|
| Storage | 30 | 60 | 100 |
| Seats | 20 | 55 | 95 |
| Support | 35 | 70 | 90 |
| API | 25 | 80 | 85 |
| Security | 50 | 65 | 98 |
| Analytics | 40 | 75 | 88 |
Colours#
Series take the chart palette in the order of config, and keep their colour when another is hidden. Give a series its own with 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.
| Token | Hue | Token | Hue |
|---|---|---|---|
--chart-series-1 | blue | --chart-series-5 | magenta |
--chart-series-2 | orange | --chart-series-6 | green |
--chart-series-3 | aqua | --chart-series-7 | violet |
--chart-series-4 | amber | --chart-series-8 | red |
The grid and spokes are hairlines in the border colour and the axis names are in the muted text colour, so the data is the loud part. Two or three series read well on one grid; past that, small multiples are easier to compare.
Motion#
- Grow: the first time the chart scrolls into view, the polygons scale out from the centre on the
revealrole, once per mount. - Morph: when
data,configor the visible series change, each vertex moves to its new place on themoverole. A series being shown grows from the centre; one being hidden shrinks into it. A new axis' vertex grows from the centre too. - Glide: the dots and the tooltip glide between axes on the
gliderole.
All follow the motion speed of the region they sit in. Reduce Motion and the instant speed draw the chart at once and drop the glide; animate={false} does the same for one chart.
API Reference#
RadarChart#
All other props go to the root <div>.
| Prop | Type | Default |
|---|---|---|
data | TDatum[] | required |
config | ChartConfig | required |
index | keyof TDatum | required: names each axis |
label | string | required: the accessible name |
formatValue | (value: number, key: string) => string | 1,234 |
legend | boolean | on for two or more series |
tooltip | boolean | true |
animate | boolean | true |
loading | boolean | false |
empty | ReactNode | "No data" |
onActiveChange | (active: ChartActive<TDatum> | null) => void | - |
ChartConfig#
| Field | Type | Default |
|---|---|---|
label | string | required |
color | ChartColor | the next palette slot |
Data attributes#
| Attribute | Element | Present when |
|---|---|---|
data-slot="radar-chart" | root | always |
data-loading | root | loading is true |
data-slot="chart-plot" | the plot | always |
data-slot="radar-chart-grid" | the grid | there is data |
data-slot="radar-chart-spoke" | a spoke | always; data-active when its axis is inspected |
data-slot="radar-chart-label" | an axis name | always; data-active when its axis is inspected |
data-slot="radar-chart-area" | a wash | always; data-dimmed while another is spotlit |
data-slot="radar-chart-series" | an outline | always; data-dimmed while another is spotlit |
data-slot="chart-legend" | the legend | the legend shows |
data-slot="chart-tooltip" | the tooltip | an axis is inspected |
Accessibility#
- The plot is a slider named after
label("Customer scorecard: inspect values"). Tab to it, then the arrow keys step through the axes clockwise, Home and End jump to the first and last, and Escape lets go. Its value text reads the tooltip: the axis and every series' value on it. - Every value is also in a table hidden from sight, a row per axis and a column per series.
- With two or more series the legend always shows, so no series is told apart by colour alone. Its items are toggle buttons with
aria-pressed. - Text never takes a series colour: axis names and values stay in the text colours, beside a coloured key.
loadingsetsaria-busyon the root and dims the last drawing until new data arrives.