Charts and graphs · @jengacore/chart-radial
Radial bar chart
Progress of 2 to 4 measures against one maximum, one ring each on a muted track.
Rollout progressMerchant onboarding is furthest along at 82%; branches trail at 45%.
| Measure | Progress |
|---|---|
| Merchants onboarded | 82% |
| Agents trained | 64% |
| Branches live | 45% |
Install
terminal
npx shadcn@latest add @jengacore/chart-radialWithout the namespace configured: npx shadcn@latest add https://ui.jengacore.com/r/<new-york-v4|base-nova>/chart-radial.json
Registry dependencies
Source
components/blocks/chart-radial.tsx
"use client"
import { PolarAngleAxis, RadialBar, RadialBarChart } from "recharts"
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { ChartFigure, type ChartCopy, seriesColor, slug } from "@/components/jc/chart-figure"
export type Progress = { name: string; value: number; color?: string }
const SAMPLE: Progress[] = [
{ name: "Merchants onboarded", value: 82 },
{ name: "Agents trained", value: 64 },
{ name: "Branches live", value: 45 },
]
/**
* Radial bars: progress of 2–4 measures against the same maximum (100 by default), one ring each on a muted track.
* The first measure is the innermost ring; the legend and the data table name every ring.
*/
export function ChartRadial({
data = SAMPLE,
max = 100,
unit = "%",
title = "Rollout progress",
summary = "Merchant onboarding is furthest along at 82%; branches trail at 45%.",
showTable,
className,
}: {
max?: number
unit?: string
showTable?: boolean
className?: string
} & ChartCopy<Progress[]>) {
const rows = data.map((d, i) => ({ ...d, key: slug(d.name, i), fill: `var(--color-${slug(d.name, i)})`, color: d.color ?? seriesColor(i) }))
const config = Object.fromEntries(rows.map((d) => [d.key, { label: d.name, color: d.color }]))
return (
<ChartFigure
title={title}
summary={summary}
data={rows.map((d) => ({ name: d.name, value: `${d.value.toLocaleString("en")}${unit}` }))}
columns={[
{ key: "name", label: "Measure" },
{ key: "value", label: "Progress" },
]}
showTable={showTable}
className={className}
>
<ChartContainer config={config} className="mx-auto aspect-square h-64">
<RadialBarChart data={rows} accessibilityLayer title={title} innerRadius="28%" outerRadius="80%" startAngle={90} endAngle={-270}>
<PolarAngleAxis type="number" domain={[0, max]} tick={false} axisLine={false} />
<ChartTooltip cursor={false} content={<ChartTooltipContent nameKey="key" hideLabel />} />
<RadialBar dataKey="value" background cornerRadius={4} isAnimationActive={false} />
<ChartLegend itemSorter={(item) => rows.findIndex((r) => r.key === (item.payload as { key?: string } | undefined)?.key)} content={<ChartLegendContent nameKey="key" />} className="flex-wrap gap-2" />
</RadialBarChart>
</ChartContainer>
</ChartFigure>
)
}