Radar Chart
Compare several things on the same axes, one filled shape each, with axis tooltips, a series legend and a keyboard-readable plot.
import { RadarChart, RadarChartAxis, RadarChartSeries } from '@youj/react'
Installation & usage
npm i @youj/reactFor an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.
Use a radar chart to compare a handful of things on the same few measures, when the overall shape matters more than any one number: models, plans, candidates, products. Keep it to three to eight axes and a few series. For one thing over time use a Sparkline; for exact values side by side, a table; the Compare items card pairs this chart with an overview table.
import { RadarChart } from '@youj/react'
<RadarChart
label="Assistants compared"
axes={[
{ id: 'reasoning', label: 'Reasoning', description: 'How well it works through multi-step problems.' },
{ id: 'speed', label: 'Speed' },
{ id: 'safety', label: 'Safety' },
]}
series={[
{ id: 'atlas', name: 'Atlas 2', values: [88, 56, 80] },
{ id: 'quill', name: 'Quill S', values: [64, 92, 72] },
]}
/>axes are drawn clockwise from the top, and each series gives one value per axis in the same order. The scale runs from zero at the center to max at the outer ring (by default the largest value rounded up to a round number; pass one to keep the scale still as data changes), divided by rings. Series take the chart colors in order unless they set a tone. formatValue writes values with their unit, and legendEnd adds your own controls beside the legend. Fewer than three axes, or no series, shows the empty state.
Description
Three made-up assistants scored on eight things. Hover or focus an axis label to see what it measures, hover or focus a point to read its value, and press a name in the legend to take its shape out of the plot.
Two weekly check-ins on a fixed 0 to 10 scale with five rings, and values written with their scale.
Code
radar-chart-demo.tsx, the Demo story. The component itself comes from the package.
Reference
Propsaxes, series, max, rings… (9)
Props
| Prop | Type | |
|---|---|---|
axesRequired | readonly RadarChartAxis[] | – |
seriesRequired | readonly RadarChartSeries[] | – |
max | numberThe value at the outer ring. Default: the largest value rounded up to a round number. | – |
rings | numberHow many rings divide the scale. default 4 | 4 |
formatValue | (value: number, axis: RadarChartAxis) => stringFormats values for the readout, the table and the spoken points. Default: the locale's number format. | – |
locale | stringDefault: the YoujProvider locale. | – |
label | stringNames the chart for assistive tech. Default: the labels' "Radar chart". | – |
legend | booleanShow the legend under the plot. default true | true |
legendEnd | ReactNodeRendered in place of the legend, e.g. your own series controls. | – |
config | Readonly<Record<string, { color?: string }>>A ChartConfig shared with your other charts: a series whose id is a key takes its color, so one series matches across chart types. | – |
Other props pass through: extends ComponentProps<'div'>. | ||
StylingParts and data attributes
Styling
Parts: radar-chart, radar-chart-stage, radar-chart-plot, radar-chart-ring, radar-chart-spoke, radar-chart-series, radar-chart-points, radar-chart-point, radar-chart-axis, radar-chart-readout, radar-chart-swatch, radar-chart-legend, radar-chart-legend-item, radar-chart-table and radar-chart-empty. A series has data-state (shown or hidden) and data-tone; the readout has data-state (open or closed); a legend item has data-state too. A series' color is --radar-chart-tone on its group.
MotionReveal, new values, toggling a series · reduced motion
Motion
| Moment | Tokens | ||
|---|---|---|---|
| Revealevery shape opens from the center, its corners sliding out along the spokes, when a third of the chart scrolls into view | duration.deliberateease.emphasized560ms · cubic-bezier(0.6, 0, 0.1, 1) | 560mscubic-bezier(0.6, 0, 0.1, 1) | |
| New values, toggling a seriesshapes morph to their new corners; a hidden series folds to the center | spring.smooth0.36s, bounce 0 | 0.36s, bounce 0 | |
| Lighting a series, an axis or a pointthe other shapes quiet, the spoke strengthens, the readout fades in | duration.fastease.standard140ms · cubic-bezier(0.2, 0, 0, 1) | 140mscubic-bezier(0.2, 0, 0, 1) |
Reduced motion
Drawn in place; new values and toggles land at once.
Reduced motion
The shapes are drawn in place, and new values and toggled series land at once.
AccessibilityKeyboard, focus, screen readers
Accessibility
- A named
group(yourlabel, or the labels' "Radar chart"). Every point is an image named "series, axis: value" ("Atlas 2, Reasoning: 88"), and a visually hidden table holds every number, with the series as columns and the axes as rows. - The plot is one tab stop. Left and Right walk the axes, Up and Down the series, Home and End go to the first and last axis, and Escape lets go. Focusing a point reads it out beside the point and lights its series, as hovering it does.
- An axis with a
descriptionis a focusable label: its tooltip appears on hover or focus, and the sentence is also the label's accessible description. - The legend is a row of toggle buttons (
aria-pressed), each reachable with Tab. Color is never the only cue: every series is named in the legend, the readout and the table. - Its built-in text comes from the labels, so
<YoujProvider labels>translates it.