RadarChart
Compare a few items across several measures on a radar, or show progress toward goals as radial bars.
Status: beta. Category: Data display.
import { RadarChart, RadialBarChart } from '@glyphui/ui/chart'
Exports: RadarChart, RadialBarChart.
Notes
- Keep radars to two or three series and five to eight spokes; more becomes unreadable.
- RadialBarChart rings run to max, or to the largest value when max is not set.
RadarChart props
| Prop | Type | Default | Description |
|---|---|---|---|
data (required) | readonly T[] | ||
index (required) | string | Field naming each spoke, e.g. "skill". | |
series (required) | readonly ChartSeries<T>[] | ||
title (required) | string | ||
className | string | ||
defaultHiddenSeries | readonly Extract<keyof T, string>[] | ||
description | ReactNode | ||
empty | ReactNode | Shown when there is no data. Defaults to a short "No data" message. | |
error | unknown | Shows an error message in place of the plot, with a retry button when onRetry is set. | |
height | number | Plot height in pixels. Default 280. | |
hiddenSeries | readonly Extract<keyof T, string>[] | ||
hideTitle | boolean | ||
loading | boolean | Shows a skeleton in place of the plot. | |
max | number | Upper bound of the radial axis. Defaults to the largest value. | |
onHiddenSeriesChange | ((hidden: Extract<keyof T, string>[]) => void) | ||
onRetry | (() => unknown) | ||
showLegend | boolean | ||
valueFormatter | ((value: number) => string) |
Example: Radar
Two plans scored on five measures.
import { RadarChart } from '@glyphui/ui/chart'
const scores = [
{ measure: 'Speed', glyph: 9, legacy: 6 },
{ measure: 'Accessibility', glyph: 9, legacy: 5 },
{ measure: 'Theming', glyph: 10, legacy: 4 },
{ measure: 'Bundle size', glyph: 7, legacy: 6 },
{ measure: 'Docs', glyph: 8, legacy: 7 },
]
export default function Example() {
return (
<RadarChart
className="w-full max-w-md"
title="Library comparison"
description="Scored out of 10"
data={scores}
index="measure"
max={10}
series={[
{ key: 'glyph', label: 'Glyph' },
{ key: 'legacy', label: 'Legacy kit' },
]}
/>
)
}
Example: Radial bars
Quarterly goals as rings.
import { RadialBarChart } from '@glyphui/ui/chart'
const goals = [
{ goal: 'New MRR', progress: 82 },
{ goal: 'Activation', progress: 64 },
{ goal: 'NPS responses', progress: 47 },
]
export default function Example() {
return (
<RadialBarChart
title="Q4 goals"
data={goals}
category="goal"
value="progress"
max={100}
valueFormatter={(v) => `${v}%`}
centerLabel={
<>
<span className="font-display text-h4 tabular-nums">64%</span>
<span className="text-caption text-muted-foreground">average</span>
</>
}
/>
)
}
Live page: https://glyphui.xyz/components/radar-chart