"use client";
import {
ChartcnRadialChart,
RadialBar,
Tooltip,
Legend,
} from "@/components/charts/radial-chart";
import type { ChartConfig } from "@/components/ui/chart";
const data = [
{ browser: "chrome", visitors: 275 },
{ browser: "safari", visitors: 200 },
{ browser: "firefox", visitors: 187 },
{ browser: "edge", visitors: 173 },
{ browser: "other", visitors: 90 },
];
const chartConfig = {
chrome: {
colors: {
dark: ["#60a5fa"],
light: ["#3b82f6"],
},
label: "Chrome",
},
edge: {
colors: {
dark: ["#a78bfa"],
light: ["#8b5cf6"],
},
label: "Edge",
},
firefox: {
colors: {
dark: ["#fbbf24"],
light: ["#f59e0b"],
},
label: "Firefox",
},
other: {
colors: {
dark: ["#9ca3af"],
light: ["#6b7280"],
},
label: "Other",
},
safari: {
colors: {
dark: ["#34d399"],
light: ["#10b981"],
},
label: "Safari",
},
} satisfies ChartConfig;
export function ChartcnExampleRadialChart() {
return (
<ChartcnRadialChart
className="h-full w-full p-4"
data={data}
nameKey="browser"
config={chartConfig}
variant="full" // [!code highlight]
>
<Legend isClickable />
<Tooltip />
<RadialBar dataKey="visitors" isClickable />
</ChartcnRadialChart>
);
}Install
$ pnpm dlx shadcn@latest add @chartcn/radial-chart
Each data row becomes an independently themed gauge ring. Use variant="semi" for a half-circle presentation.