{
  "title": "Hierarchical Partition Sunburst Radial Tree",
  "description": "Concentric multi-ring sunburst displaying nested file system hierarchy.",
  "name": "tanstack-charts-sunburst",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/sunburst.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { sunburst } from \"@tanstack/charts/hierarchy/sunburst\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { polar } from \"@tanstack/charts/polar\";\nimport { tooltip } from \"@tanstack/charts/tooltip\";\nimport { Chart } from \"@tanstack/react-charts/core\";\nimport { useMemo } from \"react\";\n\nimport { Sun } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface SunburstNode {\n    name: string;\n    size?: number;\n    branchId?: string;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): SunburstNode[] {\n    return [\n        { name: \"Analytics\", size: 100, branchId: \"b1\" },\n        { name: \"Analytics.Cluster\", size: 40, branchId: \"b1\" },\n        { name: \"Analytics.Cluster.Agglomerative\", size: 20, branchId: \"b1\" },\n        { name: \"Analytics.Cluster.KMeans\", size: 20, branchId: \"b1\" },\n        { name: \"Analytics.Graph\", size: 60, branchId: \"b1\" },\n        { name: \"Analytics.Graph.Betweenness\", size: 30, branchId: \"b1\" },\n        { name: \"Analytics.Graph.PageRank\", size: 30, branchId: \"b1\" },\n        { name: \"Display\", size: 80, branchId: \"b2\" },\n        { name: \"Display.Text\", size: 30, branchId: \"b2\" },\n        { name: \"Display.Sprite\", size: 50, branchId: \"b2\" },\n        { name: \"Physics\", size: 70, branchId: \"b3\" },\n        { name: \"Physics.Gravity\", size: 35, branchId: \"b3\" },\n        { name: \"Physics.Collision\", size: 35, branchId: \"b3\" },\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 { data?: SunburstNode; value?: number; id?: string };\n    if (!d) return { title: \"\", rows: [] };\n    const name = (d.data?.name || d.id || \"\").replaceAll(\".\", \" › \");\n    return {\n        title: name,\n        rows: [{ label: \"Proportional Node Size\", value: `${d.value ?? 0} units`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function SunburstChart() {\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.86,\n                            startAngle: Math.PI / 2,\n                            endAngle: Math.PI / 2 - Math.PI * 2,\n                            scales: {\n                                angle: null,\n                                radius: null,\n                            },\n                            marks: [\n                                sunburst(data, {\n                                    id: \"sunburst-arcs\",\n                                    path: \"name\",\n                                    delimiter: \".\",\n                                    value: \"size\",\n                                    innerRadius: ({ radius }) => radius * 0.15,\n                                    outerRadius: ({ radius }) => {\n                                        const inner = radius * 0.15;\n                                        return inner + ((radius - inner) * 2) / 3;\n                                    },\n                                    ringPadding: 2,\n                                    color: \"branchId\",\n                                    stroke: \"var(--background)\",\n                                    strokeWidth: 1.5,\n                                }),\n                            ],\n                        }),\n                    ],\n                    color: {\n                        range: [\"var(--chart-1)\", \"var(--chart-2)\", \"var(--chart-3)\"],\n                    },\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>Hierarchical Partition Sunburst Radial Ring</CardTitle>\n                <CardDescription>\n                    Concentric multi-ring sunburst displaying dot-delimited file path hierarchies\n                </CardDescription>\n            </CardHeader>\n            <CardContent>\n                <div className=\"h-[270px] w-full\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        height={270}\n                        ariaLabel=\"Hierarchical Partition Sunburst Radial Ring 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                    Multi-level partition tree with proportional arc spans <Sun className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `sunburst` mark transforms dot-delimited path strings into radial rings\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default SunburstChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Concentric multi-ring sunburst displaying nested file system hierarchy. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack"
    ]
  }
}