{
  "title": "Donut Chart with Rounded Arc Corner Caps",
  "description": "Segmented donut ring visualization with smooth rounded arc endpoints.",
  "name": "tanstack-charts-rounded-donut",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/rounded-donut.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { pie, polar, radialArc } from \"@tanstack/charts/polar\";\nimport { tooltip } from \"@tanstack/charts/tooltip\";\nimport { Chart } from \"@tanstack/react-charts/core\";\nimport { useMemo } from \"react\";\n\nimport { CircleDot } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface DonutSegment {\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 gapAngle = (Math.PI / 180) * 4;\nconst categories = [\"North America\", \"Europe\", \"Asia Pacific\", \"Latin America\", \"Middle East\"];\nconst colors = [\"var(--chart-1)\", \"var(--chart-2)\", \"var(--chart-3)\", \"var(--chart-4)\", \"var(--chart-5)\"];\n\nfunction generateDemoData(): DonutSegment[] {\n    return [\n        { category: \"North America\", value: 38 },\n        { category: \"Europe\", value: 26 },\n        { category: \"Asia Pacific\", value: 20 },\n        { category: \"Latin America\", value: 10 },\n        { category: \"Middle East\", value: 6 },\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 DonutSegment;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.category,\n        rows: [{ label: \"Regional Revenue\", value: `${d.value}%`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function RoundedDonut() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(() => {\n        const arcs = pie(data, {\n            value: \"value\",\n            gapAngle,\n        });\n\n        return defineChart(\n            {\n                renderer: motionRenderer,\n                scales: {\n                    x: null,\n                    y: null,\n                },\n                marks: [\n                    polar({\n                        radiusRatio: 0.78,\n                        scales: {\n                            angle: null,\n                            radius: null,\n                        },\n                        marks: [\n                            radialArc(arcs, {\n                                id: \"rounded-slices\",\n                                key: \"category\",\n                                innerRadius: ({ radius }) => radius * 0.58,\n                                cornerRadius: 8,\n                                color: \"category\",\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: \"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    return (\n        <Card className=\"w-full max-w-xl\">\n            <CardHeader>\n                <CardTitle>Donut Chart with Rounded Arc Corners & Sector Gaps</CardTitle>\n                <CardDescription>\n                    Segmented donut ring visualization with explicit corner radiuses and angular padding gaps\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=\"Donut Chart with Rounded Arc Corners & Sector Gaps 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                    Rounded arc corners deliver modern smooth pill aesthetics{\" \"}\n                    <CircleDot className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `cornerRadius: 8` and `gapAngle` parameters sculpt pill-shaped ring sectors\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default RoundedDonut;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Segmented donut ring visualization with smooth rounded arc endpoints. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "pie"
    ]
  }
}