shadcn.io is not affiliated with official shadcn/ui
Chart examples · Radar
A radar chart with icons for React
A radar chart whose legend shows an icon for each series.
Use icons when color alone shouldn't identify a series. Each series in the chart config has an icon, and ChartLegendContent draws it beside the label in the legend under the chart.
Preview
Installation
FAQ
How do the legend icons get there?
Set icon on each entry in config. Desktop uses ArrowDownFromLineIcon and mobile uses ArrowUpFromLineIcon, next to the labels Desktop and Mobile. ChartLegendContent renders that component in place of the color swatch.
Do the icons use the series color?
No. The legend paints them with text-muted-foreground at size-3. The series color stays on the polygon: fill is var(--color-desktop) or var(--color-mobile), from each entry's color (var(--chart-1) and var(--chart-2)).
Does the tooltip show the same icons?
Yes. ChartTooltipContent draws the icon from config on each row, so indicator="line" only appears for a series that has no icon. cursor={false} on ChartTooltip turns the hover cursor off.
Why is one polygon more transparent?
The desktop Radar sets fillOpacity={0.6}. The mobile Radar doesn't set fillOpacity, so that shape paints solid. Both read the same chartData rows, one with dataKey="desktop" and one with dataKey="mobile".
Related
- A radar chart with a legendA radar chart comparing two series with a
- A radar chart with multiple dataA radar chart overlaying desktop and
- An area chart with iconsA stacked area chart whose legend and
- A multiple line chartA line chart comparing desktop and mobile
- A radar chart with a custom labelA radar chart whose axis labels show both
- A radar chartA radar chart plotting one series across