shadcn.io is not affiliated with official shadcn/ui
Chart examples · Radar
A radar chart with a custom label for React
A radar chart whose axis labels show both values and the month at each point.
Use it when the axis labels should carry the numbers. The tick of PolarAngleAxis is a function that prints each month's desktop and mobile values above its name, so both series can be read without a hover.
Preview
Installation
FAQ
How do the axis labels show both values and the month?
PolarAngleAxis sets dataKey to month and tick to renderTick. That function reads chartData[index] and returns a text node with the desktop count, a slash, the mobile count, and the month on a second line.
How is that label text styled?
The text uses className fill-foreground, fontSize 13, and fontWeight 500. The slash and the month tspan use fill-muted-foreground. The month tspan also sets dy to 1rem, fontSize to 12, and x to the tick's x.
Why is the first label shifted up?
When index is 0, renderTick sets y to Number(y) - 10. The other months use the y they were given. RadarChart sets margin to 10 on every side.
Which series are filled?
One Radar uses dataKey desktop, fill var(--color-desktop), and fillOpacity 0.6. The other uses dataKey mobile and fill var(--color-mobile). config colors them with var(--chart-1) and var(--chart-2).
Related
- A radar chartA radar chart plotting one series across
- A line chart with a custom labelA line chart labeling each point with its
- A radar chart with multiple dataA radar chart overlaying desktop and
- A pie chart with a custom labelA pie chart printing each slice's value
- A radar chart with a legendA radar chart comparing two series with a
- A bar chart with a custom labelA horizontal bar chart with the month