shadcn.io is not affiliated with official shadcn/ui
Chart examples · Radial
A radial chart with text for React
A radial bar chart with one rounded ring and its value in the center.
Use it for a single value shown as a ring with the number in the middle. One rounded arc sits on a muted track, and a Label writes the value and the word Visitors in the center.
Preview
Installation
FAQ
How does the number get into the center?
PolarRadiusAxis hides its line, ticks, and tick line, and renders a Label with content={renderValue}. renderValue checks viewBox for cx and cy, then draws a text at that point with textAnchor="middle" and dominantBaseline="middle".
What text does it actually print?
The value is chartData[0].visitors passed through toLocaleString, which is 200 here. The caption is the string Visitors. The value uses fill-foreground font-bold text-4xl at viewBox.cy. The caption uses fill-muted-foreground at viewBox.cy + 24.
How long is the ring?
RadialBarChart sets startAngle={0} and endAngle={250}, so the arc runs 250 degrees from the right side of the circle. innerRadius={80} and outerRadius={110} set the thickness. RadialBar sets cornerRadius={10} to round the cap, background for the track, and dataKey="visitors".
What are the circles inside the ring?
PolarGrid sets gridType="circle", polarRadius={[86, 74]}, radialLines={false}, and stroke="none". The className fills the first circle with fill-muted and the last with fill-background. They are decoration around the hole, not a scale for visitors.
Related
- A radial chart with a custom shapeA radial bar chart with one partial ring
- A radial chartA radial bar chart with one ring per
- A donut chart with textA donut chart with the total number of
- A radial chart with stacked sectionsA half-circle radial chart stacking
- A radial chart with a labelA radial bar chart labeling each ring
- A radial chart with a gridA radial bar chart with circular grid