{
  "title": "Gauge Chart",
  "description": "Radial gauge metric dial indicating completion percentage.",
  "name": "tanstack-charts-gauge-chart",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/gauge-chart.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 { Gauge } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface GaugeSegment {\n    id: \"value\" | \"remainder\";\n    label: 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 startAngle = (-Math.PI * 3) / 4;\nconst endAngle = (Math.PI * 3) / 4;\n\nfunction generateDemoData(): GaugeSegment[] {\n    const value = 78;\n    return [\n        { id: \"value\", label: \"System Health Score\", value },\n        { id: \"remainder\", label: \"Remaining Gap\", value: 100 - value },\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 GaugeSegment;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.label,\n        rows: [\n            { label: \"Percentage\", value: `${d.value}%`, color: d.id === \"value\" ? \"var(--chart-1)\" : \"var(--muted)\" },\n        ],\n    };\n}\n\nexport function GaugeChart() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const arcs = useMemo(() => {\n        return pie(data, {\n            value: \"value\",\n            startAngle,\n            endAngle,\n        });\n    }, [data]);\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                            inset: 0,\n                            radiusRatio: 0.8,\n                            scales: {\n                                angle: null,\n                                radius: null,\n                            },\n                            marks: [\n                                radialArc(arcs, {\n                                    id: \"gauge-segments\",\n                                    key: \"id\",\n                                    innerRadius: ({ radius }: { radius: number }) => radius * 0.72,\n                                    color: \"id\",\n                                    stroke: \"var(--background)\",\n                                    strokeWidth: 2,\n                                }),\n                            ],\n                        }),\n                    ],\n                    color: {\n                        domain: [\"value\", \"remainder\"],\n                        range: [\"var(--chart-1)\", \"var(--muted)\"],\n                    },\n                    margin: 10,\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        [arcs],\n    );\n\n    return (\n        <Card className=\"w-full max-w-xl\">\n            <CardHeader>\n                <CardTitle>Radial Gauge Metric Dial</CardTitle>\n                <CardDescription>\n                    Arc meter dial indicating percentage completion relative to maximum target\n                </CardDescription>\n            </CardHeader>\n            <CardContent>\n                <div className=\"flex h-[250px] w-full items-center justify-center\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        height={250}\n                        ariaLabel=\"Radial Gauge Metric Dial 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                    System health operating at 78% optimal target <Gauge className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Sweeping 270-degree radial arc provides clean speedometer gauge visualization\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default GaugeChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Radial gauge metric dial indicating completion percentage. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack"
    ]
  }
}