{
  "title": "Concentric Circular Radial Metric Bars",
  "description": "Concentric stacked rings with rounded pill caps tracking progress.",
  "name": "tanstack-charts-radial-bars",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/radial-bars.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { polar, radialBarAngle } from \"@tanstack/charts/polar\";\nimport { tooltip } from \"@tanstack/charts/tooltip\";\nimport { Chart } from \"@tanstack/react-charts/core\";\nimport { useMemo } from \"react\";\n\nimport { scaleBand, scaleLinear } from \"d3-scale\";\nimport { CircleDot } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface RadialMetric {\n    category: string;\n    value: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nconst categories = [\"Activity Goal\", \"Calorie Burn\", \"Hydration\", \"Sleep Quality\"];\nconst colors = [\"var(--chart-1)\", \"var(--chart-2)\", \"var(--chart-3)\", \"var(--chart-4)\"];\n\nfunction generateDemoData(): RadialMetric[] {\n    return [\n        { category: \"Activity Goal\", value: 85 },\n        { category: \"Calorie Burn\", value: 65 },\n        { category: \"Hydration\", value: 90 },\n        { category: \"Sleep Quality\", value: 75 },\n    ];\n}\n\nfunction shadcnTooltipContent<TDatum>(points: readonly ChartPoint<TDatum>[]) {\n    if (points.length === 0) return { title: \"\", rows: [] };\n    const d = points[0].datum as RadialMetric;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.category,\n        rows: [{ label: \"Target Completion\", value: `${d.value}%`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function RadialBars() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    scales: {\n                        x: null,\n                        y: null,\n                    },\n                    marks: [\n                        polar({\n                            radiusRatio: 0.82,\n                            scales: {\n                                angle: {\n                                    scale: scaleLinear().domain([0, 100]),\n                                },\n                                radius: {\n                                    scale: () =>\n                                        scaleBand<string>().domain(categories).paddingInner(0.35).paddingOuter(0.15),\n                                    range: [({ radius }) => radius * 0.2, ({ radius }) => radius],\n                                },\n                            },\n                            marks: [\n                                radialBarAngle(data, {\n                                    id: \"category-bars\",\n                                    angle: \"value\",\n                                    radius: \"category\",\n                                    key: \"category\",\n                                    color: \"category\",\n                                    cornerRadius: \"full\",\n                                }),\n                            ],\n                        }),\n                    ],\n                    color: { domain: categories, range: colors },\n                    margin: { top: 20, right: 20, bottom: 20, left: 20 },\n                    theme: {\n                        foreground: \"var(--muted-foreground)\",\n                        grid: \"var(--border)\",\n                        background: \"transparent\",\n                    },\n                },\n                {\n                    keyboard: true,\n                    tooltip: {\n                        use: tooltip,\n                        className:\n                            \"font-sans shadow-none rounded-md bg-popover text-popover-foreground border p-2 text-xs\",\n                        anchor: \"pointer\",\n                        placement: \"auto\",\n                        content: (points) => shadcnTooltipContent(points),\n                    },\n                },\n            ),\n        [data],\n    );\n\n    return (\n        <Card className=\"w-full max-w-xl\">\n            <CardHeader>\n                <CardTitle>Concentric Circular Radial Metric Bars</CardTitle>\n                <CardDescription>\n                    Concentric stacked rings with rounded pill caps tracking progress metrics\n                </CardDescription>\n            </CardHeader>\n            <CardContent>\n                <div className=\"h-[250px] w-full\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        height={250}\n                        ariaLabel=\"Concentric Circular Radial Metric Bars Chart\"\n                    />\n                </div>\n            </CardContent>\n            <CardFooter className=\"flex-col items-start gap-2 text-sm\">\n                <div className=\"flex items-center gap-2 leading-none font-medium\">\n                    Apple Watch-style concentric progress rings with pill caps{\" \"}\n                    <CircleDot className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `radialBarAngle` maps values to arc angles across nested band scale radiuses\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default RadialBars;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Concentric stacked rings with rounded pill caps tracking progress. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "bar"
    ]
  }
}