shadcn.io is not affiliated with official shadcn/ui
Chart examples · Radial
A radial chart with stacked sections for React
A half-circle radial chart stacking desktop and mobile with the total in its center.
Use it to show two parts of one total as a half gauge. Desktop and mobile are stacked on one half-circle arc with rounded ends, and the center shows their sum.
Preview
Installation
FAQ
How do desktop and mobile share one arc?
Both RadialBar components set stackId="a". Desktop uses dataKey="desktop" and mobile uses dataKey="mobile", on a single chartData row. The same stackId lays those values end to end in one band.
How do I make it a half circle?
RadialBarChart sets endAngle={180} and leaves the start at 0, the right side of the circle. innerRadius={80} and outerRadius={130} set the band. The frame is aspect-square w-full max-w-[250px].
How are the ends rounded, and why is there a gap?
Each RadialBar sets cornerRadius={5}, which rounds the cap. The className is stroke-2 stroke-transparent, a transparent stroke that separates the two stacked segments. Fills are var(--color-desktop) and var(--color-mobile).
How is the center total calculated?
renderTotal is the Label content on PolarRadiusAxis. It sums desktop and mobile with reduce, then calls toLocaleString. The caption under it is the text Visitors. The axis itself sets axisLine, tick, and tickLine to false.
Related
- A radial chart with a custom shapeA radial bar chart with one partial ring
- A radial chart with textA radial bar chart with one rounded ring
- A stacked bar chart with a legendA bar chart stacking desktop and mobile
- A stacked area chartAn area chart stacking desktop and mobile
- A pie chart with stacked sectionsTwo nested pie rings comparing desktop
- A radial chartA radial bar chart with one ring per