shadcn.io is not affiliated with official shadcn/ui
About
Use it when readers judge each ring by how far it gets around the circle and need marks to measure against. The circles and spokes do the job the track does in the plain radial chart, without filling the card with gray. For exact comparisons, a horizontal bar chart is still easier.
Five rings, Chrome innermost, each start at three o'clock and run counterclockwise as far as their visitor counts. A thin circle sits at every ring's radius and spokes cross them at even steps of the value scale.
Installation
Usage
import { ChartRadialGrid } from "@/components/charts/chart-radial-grid";<ChartRadialGrid />Customize
<PolarGrid gridType="circle" />draws the circles and spokes. Recharts places them from the radius and angle axes, so they follow the rings.<RadialBar dataKey="visitors" />has nobackgroundhere, so the grid shows through between rings.innerRadius={30}andouterRadius={100}on<RadialBarChart>set the rings' band.- Each row's
fill,var(--color-chrome)and so on, colors its ring fromchartConfig. <ChartTooltipContent hideLabel nameKey="browser" />names the hovered ring by its browser.
FAQ
How are the circles and spokes drawn?
<PolarGrid gridType="circle" /> inside <RadialBarChart> draws a circle per ring and the radial lines. ChartContainer turns its strokes to the border token. The default gridType is polygon.
How do I keep the circles and remove the spokes?
Set radialLines={false} on <PolarGrid>. To place the spokes yourself, pass polarAngles an array of angles in degrees.
Can I add a track behind each ring?
Add background to <RadialBar>; ChartContainer fills it with the muted token. With a track, the grid becomes noise, so most charts keep one or the other.
API Reference
ChartContainer
configChartConfig
Each series by its data key: its label, an icon, and a color (or a * theme color per light and dark), read by the tooltip and legend and set * as --color-<key>.
initialDimension?{ height: number; width: number; }
The size it renders at before it's measured, so the first paint isn't * empty.
- Type
{ height: number; width: number; }- Default
INITIAL_DIMENSION
className?string
Merged with the part's classes.
ChartLegend
ChartLegendContent
<div>
hideIcon?boolean
Hides each series' icon (from config), leaving its color swatch.
- Default
false
nameKey?string
The key in each legend item's data to look its label up by in config. * Defaults to the item's dataKey.
className?string
Merged with the part's classes.
ChartStyle
<style>
configChartConfig
The chart config whose colors it writes as --color-<key> variables.
idstring
The element's id.
ChartTooltip
ChartTooltipContent
<div>
hideIndicator?boolean
Hides each item's color indicator.
- Default
false
hideLabel?boolean
Hides the tooltip's label, the hovered point's.
- Default
false
indicator?"dashed" | "dot" | "line"
The color indicator's shape: a dot, a line or dashed.
- Type
"dashed" | "dot" | "line"- Default
"dot"
labelFormatter?(label: any, payload: TooltipPayload) → React.ReactNode
Formats the tooltip's label; its value is untyped, as in recharts 3.8.
- Type
(label: any, payload: TooltipPayload) → React.ReactNode- Parameters
label– anypayload– TooltipPayload- Returns
React.ReactNode
labelKey?string
The key in the data to read the label from, looked up in config.
nameKey?string
The key in each item's data to look its name up by in config.
className?string
Merged with the part's classes.
Related
Radial Chart
Radial chartsOne ring per browser, each as long as its share.
Radial Chart with Labels
Radial chartsRadial bars with each browser's name written at its start.
Radar Chart with Circle Grid
Radar chartsA radar on circular grid rings instead of polygons.
Radar Chart with Circle Grid, No Lines
Radar chartsCircular grid rings with no spokes from the center.
Horizontal Bar Chart
Bar chartsHorizontal bars with the categories down the side.
Radial Chart with Text
Radial chartsOne ring of progress with the total in its center.