RadarChart
Several measures compared across shared categories, drawn as an outline around a centre
Usage
RadarChart is imported from its own subpath and needs the optional recharts peer.
npm install rechartsimport {RadarChart} from "@peakui-pro/react/radar-chart";Anatomy
import {RadarChart} from "@peakui-pro/react/radar-chart";
// Only the root is this package's own; the parts are the charting library's components under
// PeakUI names. The root is not exported from `@peakui-pro/react`, so an app that renders no
// chart never needs the peer installed, not even to render on a server.
export default () => (
<RadarChart aria-label="Skill assessment" data={[]}>
<RadarChart.Grid />
<RadarChart.AngleAxis dataKey="skill" />
<RadarChart.RadiusAxis />
<RadarChart.Radar dataKey="score" />
<RadarChart.Tooltip content={<RadarChart.TooltipContent />} />
</RadarChart>
);Data belongs to the chart
data is one object per spoke. AngleAxis reads the spoke's name from dataKey; each Radar
reads its own field from every row. Two Radars over the same rows are a comparison.
Colouring a series
A Radar takes its colour from stroke and fill; set both to a token of the series ramp,
var(--chart-2) … var(--chart-5), and lower fillOpacity so overlapping areas stay legible
(0.15 for one or two series, 0.1 for three). --chart-1 is the darkest step and has too little
contrast on a dark surface, so the examples on this page do not use it.
Dots
dot draws a marker at each value. Give it fillOpacity: 1 for a solid one. With fill="none" on
the Radar the dots inherit the missing fill, so pass their fill as well (see Dots Only).
Zero and empty data
A chart whose data is empty renders its container and draws no outline. Show your own empty state
beside it.
Accessibility
The plot takes focus and answers the arrow keys, so aria-label names it, not the wrapper.
Series are told apart by colour; add a second cue the reader can use without it: name each series
in a legend, show dot markers, or give a series a strokeDasharray.
// Named by a string, or by the element that already carries the chart's title.
<RadarChart aria-label="Skill assessment" data={data}>{/* … */}</RadarChart>
<RadarChart aria-labelledby="skills-title" data={data}>{/* … */}</RadarChart>
// A chart that only repeats a figure printed beside it leaves the keyboard layer out.
<RadarChart accessibilityLayer={false} data={data}>{/* … */}</RadarChart>Examples
Comparison
Two series over the same spokes.
Multi Series
Three series; lighter fills keep their overlaps legible.
Dots Only
fill="none" drops the area. The dots inherit it, so they take their own fill.
With Radius Axis
RadiusAxis prints the scale along one spoke. angle places it and domain fixes the scale.
Customization
Tailwind CSS
<RadarChart className="mx-auto max-w-md" data={data} height={280} />Global CSS
@layer components {
.chart-polar {
--chart-axis-size: 11px;
--chart-grid-opacity: 0.4;
}
}Styling Reference
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
CSS Classes
The RadarChart component uses these CSS classes (view source styles):
Base Classes
.chart-polar- The block every polar chart carries; grid, tick text, the hidden tooltip cursor and the raised tooltip.radar-chart- This chart's own block; gives the root its width, sets the category labels to 11px and rounds the outline's joins
Slots
[data-slot="radar-chart"]- The root element
CSS Variables
| Variable | Purpose |
|---|---|
--chart-axis-size | Type size of tick text; set on .chart-polar |
--chart-grid-opacity | How far the polar grid recedes behind the data; set on .chart-polar |
--chart-1 … --chart-5 | The series ramp, derived from the theme's accent |
API Reference
RadarChart
| Prop | Type | Default | Description |
|---|---|---|---|
data | Record<string, number | string | null>[] | - | One object per spoke; each series reads its own field |
height | number | `${number}%` | 300 | Height of the plot |
width | number | `${number}%` | '100%' | Width of the plot |
accessibilityLayer | boolean | true | Whether the plot is focusable and answers the arrow keys |
children | ReactNode | - | The chart's parts |
aria-label | string | - | Names the plot, which is what takes focus — not the wrapping <div> |
aria-labelledby | string | - | Names the plot by another element's id |
className | string | - | Additional classes |
...rest | ComponentProps<'div'> | - | Native <div> attributes, on the wrapper |
There is no margin: a polar chart sizes itself from its container.
RadarChart.Radar
The charting library's Radar, re-exported. See the Recharts Radar API.
RadarChart.Grid
The charting library's PolarGrid, re-exported. See the Recharts PolarGrid API.
RadarChart.AngleAxis
The charting library's PolarAngleAxis, re-exported. See the Recharts PolarAngleAxis API.
RadarChart.RadiusAxis
The charting library's PolarRadiusAxis, re-exported. See the Recharts PolarRadiusAxis API.
RadarChart.Tooltip
The charting library's Tooltip, re-exported. See the Recharts Tooltip API.
RadarChart.TooltipContent
ChartTooltip.Content, for the content prop of RadarChart.Tooltip. Its props are on the ChartTooltip page.