{
  "title": "Radar Chart",
  "description": "Multivariate polar radar spider chart evaluating multi-axis performance dimensions.",
  "name": "tanstack-charts-radar-chart",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale",
    "d3-shape"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/radar-chart.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { angleGrid, polar, radialArea, radialGrid } from \"@tanstack/charts/polar\";\nimport { tooltip } from \"@tanstack/charts/tooltip\";\nimport { Chart } from \"@tanstack/react-charts/core\";\nimport { useMemo } from \"react\";\n\nimport { scaleLinear, scalePoint } from \"d3-scale\";\nimport { curveLinearClosed } from \"d3-shape\";\nimport { Compass } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface SkillDatum {\n    skill: string;\n    score: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nconst radarSkills = [\"Speed\", \"Endurance\", \"Strength\", \"Agility\", \"Flexibility\", \"Precision\"];\n\nfunction generateDemoData(): SkillDatum[] {\n    const scores = [85, 92, 78, 88, 70, 95];\n    return radarSkills.map((skill, idx) => ({\n        skill,\n        score: scores[idx] / 100,\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 SkillDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.skill,\n        rows: [{ label: \"Performance Score\", value: `${(d.score * 100).toFixed(0)}%`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function RadarChart() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const angleScale = useMemo(() => scalePoint<string>().domain(radarSkills), []);\n    const radiusScale = useMemo(() => scaleLinear().domain([0, 1]), []);\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                            scales: {\n                                angle: { scale: angleScale, wrap: true },\n                                radius: { scale: radiusScale },\n                            },\n                            inset: 0,\n                            radiusRatio: 0.8,\n                            guides: [\n                                radialGrid({\n                                    values: [0.2, 0.4, 0.6, 0.8, 1],\n                                    shape: \"polygon\",\n                                    labels: true,\n                                    labelFontSize: 10,\n                                    format: (v) => `${Math.round(Number(v) * 100)}%`,\n                                    labelFill: \"var(--muted-foreground)\",\n                                    stroke: \"var(--border)\",\n                                }),\n                                angleGrid({\n                                    values: radarSkills,\n                                    labels: true,\n                                    labelOffset: 10,\n                                    labelFill: \"var(--foreground)\",\n                                    labelFontSize: 11,\n                                    format: String,\n                                    stroke: \"var(--border)\",\n                                }),\n                            ],\n                            marks: [\n                                radialArea(data, {\n                                    id: \"athlete-profile\",\n                                    angle: \"skill\",\n                                    radius: \"score\",\n                                    key: \"skill\",\n                                    curve: curveLinearClosed,\n                                    fill: \"var(--chart-1)\",\n                                    fillOpacity: 0.45,\n                                    stroke: \"var(--chart-1)\",\n                                    strokeWidth: 2,\n                                }),\n                            ],\n                        }),\n                    ],\n                    margin: 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, angleScale, radiusScale],\n    );\n\n    return (\n        <Card className=\"w-full max-w-xl\">\n            <CardHeader>\n                <CardTitle>Multivariate Polar Radar Spider Chart</CardTitle>\n                <CardDescription>Closed radial polygon plot evaluating multi-axis performance ratings</CardDescription>\n            </CardHeader>\n            <CardContent>\n                <div className=\"flex h-[280px] w-full items-center justify-center\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        height={280}\n                        ariaLabel=\"Multivariate Polar Radar Spider 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                    Precision and Endurance score highest at 95% and 92%{\" \"}\n                    <Compass className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Polygon radial grid guides partition equal angular spans for each attribute dimension\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default RadarChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Multivariate polar radar spider chart evaluating multi-axis performance dimensions. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "radar"
    ]
  }
}