Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Radar Chart

PreviousNext

Several measures of one or more subjects on shared axes, as polygons over a hairline grid.

Customer scorecard
Acme Inc against the industry, out of 100
Customer scorecard
Acme IncIndustry average
Performance8670
Reliability9275
Usability7872
Support8866
Price6470
Integrations7268

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 skills
Design team
Research70
Interface92
Prototyping85
Writing60
Accessibility78

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.

Plans compared
StarterProEnterprise
Storage3060100
Seats205595
Support357090
API258085
Security506598
Analytics407588

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.

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

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 reveal role, once per mount.
  • Morph: when data, config or the visible series change, each vertex moves to its new place on the move role. 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 glide role.

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>.

PropTypeDefault
dataTDatum[]required
configChartConfigrequired
indexkeyof TDatumrequired: names each axis
labelstringrequired: the accessible name
formatValue(value: number, key: string) => string1,234
legendbooleanon for two or more series
tooltipbooleantrue
animatebooleantrue
loadingbooleanfalse
emptyReactNode"No data"
onActiveChange(active: ChartActive<TDatum> | null) => void-

ChartConfig

FieldTypeDefault
labelstringrequired
colorChartColorthe next palette slot

Data attributes

AttributeElementPresent when
data-slot="radar-chart"rootalways
data-loadingrootloading is true
data-slot="chart-plot"the plotalways
data-slot="radar-chart-grid"the gridthere is data
data-slot="radar-chart-spoke"a spokealways; data-active when its axis is inspected
data-slot="radar-chart-label"an axis namealways; data-active when its axis is inspected
data-slot="radar-chart-area"a washalways; data-dimmed while another is spotlit
data-slot="radar-chart-series"an outlinealways; data-dimmed while another is spotlit
data-slot="chart-legend"the legendthe legend shows
data-slot="chart-tooltip"the tooltipan 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.
  • loading sets aria-busy on the root and dims the last drawing until new data arrives.