{
  "title": "Comparative Polygon Spider Radar Overlay",
  "description": "Multi-entity polygon radar overlay evaluating performance dimensions.",
  "name": "tanstack-charts-comparative-radar",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale",
    "d3-shape"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/pie/comparative-radar.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 { ShieldAlert } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface RadarScoreDatum {\n    entity: string;\n    attribute: 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 attributes = [\"Speed\", \"Reliability\", \"Security\", \"Scalability\", \"Usability\"];\nconst entities = [\"Product A\", \"Product B\"];\nconst colors = [\"var(--chart-1)\", \"var(--chart-2)\"];\nconst ringValues = [0.2, 0.4, 0.6, 0.8, 1];\n\nfunction generateDemoData(): RadarScoreDatum[] {\n    const results: RadarScoreDatum[] = [];\n    const scoresA = [0.85, 0.9, 0.95, 0.7, 0.8];\n    const scoresB = [0.65, 0.75, 0.8, 0.95, 0.9];\n\n    attributes.forEach((attr, idx) => {\n        results.push({ entity: \"Product A\", attribute: attr, score: scoresA[idx] });\n        results.push({ entity: \"Product B\", attribute: attr, score: scoresB[idx] });\n    });\n\n    return results;\n}\n\nfunction shadcnTooltipContent<TDatum>(points: readonly ChartPoint<TDatum>[]) {\n    if (points.length === 0) return { title: \"\", rows: [] };\n    const d = points[0].datum as RadarScoreDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: `${d.entity} - ${d.attribute}`,\n        rows: [{ label: \"Performance Score\", value: `${Math.round(d.score * 100)}%`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function ComparativeRadar() {\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                            scales: {\n                                angle: { scale: scalePoint<string>().domain(attributes), wrap: true },\n                                radius: { scale: scaleLinear().domain([0, 1]) },\n                            },\n                            inset: 0,\n                            radiusRatio: 0.75,\n                            guides: [\n                                radialGrid({\n                                    values: ringValues,\n                                    shape: \"polygon\",\n                                    labels: true,\n                                    labelAngle: Math.PI / 4,\n                                    format: (v) => `${Number(v) * 100}%`,\n                                    labelFill: \"var(--muted-foreground)\",\n                                    stroke: \"var(--border)\",\n                                }),\n                                angleGrid({\n                                    values: attributes,\n                                    labels: true,\n                                    labelOffset: 8,\n                                    labelFill: \"var(--foreground)\",\n                                    labelFontSize: 11,\n                                    format: String,\n                                    stroke: \"var(--border)\",\n                                }),\n                            ],\n                            marks: [\n                                radialArea(data, {\n                                    id: \"country-profiles\",\n                                    angle: \"attribute\",\n                                    radius: \"score\",\n                                    color: \"entity\",\n                                    key: ({ entity, attribute }) => `${entity}:${attribute}`,\n                                    curve: curveLinearClosed,\n                                    fillOpacity: 0.2,\n                                }),\n                            ],\n                        }),\n                    ],\n                    color: {\n                        domain: entities,\n                        range: colors,\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>Comparative Polygon Spider Radar Evaluation</CardTitle>\n                <CardDescription>\n                    Multi-entity polygon radar overlay evaluating normalized multi-attribute metrics\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=\"Comparative Polygon Spider Radar Evaluation 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                    Product A vs Product B multi-axis attribute comparison{\" \"}\n                    <ShieldAlert className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `radialGrid` with polygon shape and `angleGrid` guides construct comparative spider webs\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default ComparativeRadar;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Multi-entity polygon radar overlay evaluating performance dimensions. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "radar"
    ]
  }
}