{
  "title": "Radar Chart Grid Circle",
  "description": "A radar chart with circular grid lines built with TanStack Charts.",
  "name": "tanstack-charts-radar-grid-circle",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale",
    "d3-shape"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/radar/radar-grid-circle.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { angleGrid, focusGroupAngle, polar, radialArea, radialDot, 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 { TrendingUp } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\nfunction generateDemoData() {\n    return [\n        { month: \"January\", desktop: 186 },\n        { month: \"February\", desktop: 305 },\n        { month: \"March\", desktop: 237 },\n        { month: \"April\", desktop: 273 },\n        { month: \"May\", desktop: 209 },\n        { month: \"June\", desktop: 214 },\n    ];\n}\n\nconst twoSeries = [\"desktop\", \"mobile\"] as const;\nconst chartColors = [\"var(--chart-1)\", \"var(--chart-2)\"];\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction titleCase(value: string) {\n    return value.charAt(0).toUpperCase() + value.slice(1);\n}\n\nfunction shadcnTooltipContent<TDatum>(points: readonly ChartPoint<TDatum>[]) {\n    return {\n        title: String(points[0]?.xValue ?? \"\"),\n        rows: points.map((point) => ({\n            label: titleCase(\n                String(point.group ?? point.markId.replace(/-?(bars|lines|areas|slices|values|radar)$/u, \"\")),\n            ),\n            value: Number(point.yValue ?? point.xValue ?? 0).toLocaleString(\"en-US\"),\n            color: point.color,\n        })),\n    };\n}\n\nexport function RadarGridCircle() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(() => {\n        const months = data.map((row) => row.month);\n        const radiusMax = 320;\n        const gridValues = Array.from({ length: 4 }, (_, index) => Math.round((radiusMax * (index + 1)) / 4));\n\n        const guides = [\n            radialGrid({\n                values: gridValues,\n                shape: \"circle\",\n                stroke: \"var(--border)\",\n                strokeOpacity: 1,\n            }),\n            angleGrid({\n                values: months,\n                labels: true,\n                labelOffset: 10,\n                labelFill: \"var(--muted-foreground)\",\n                labelFontSize: 12,\n                stroke: \"var(--border)\",\n                strokeOpacity: 1,\n            }),\n        ];\n\n        return defineChart(\n            {\n                renderer: motionRenderer,\n                motion: {\n                    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n                },\n                scales: {\n                    x: null,\n                    y: null,\n                },\n                marks: [\n                    polar({\n                        radiusRatio: 0.76,\n                        scales: {\n                            angle: { scale: scalePoint<string>().domain(months), wrap: true },\n                            radius: { scale: scaleLinear().domain([0, radiusMax]) },\n                        },\n                        guides,\n                        marks: [\n                            radialArea(data, {\n                                id: \"desktop-radar\",\n                                className: \"ts-chart__radar\",\n                                angle: \"month\",\n                                radius: \"desktop\",\n                                key: \"month\",\n                                z: () => \"desktop\",\n                                curve: curveLinearClosed,\n                                fill: chartColors[0],\n                                fillOpacity: 0.6,\n                                stroke: chartColors[0],\n                                strokeOpacity: 1,\n                                strokeWidth: 1,\n                            }),\n                            radialDot(data, {\n                                id: \"radar-dots\",\n                                angle: \"month\",\n                                radius: \"desktop\",\n                                key: \"month\",\n                                z: () => \"desktop\",\n                                r: 4,\n                                fill: chartColors[0],\n                            }),\n                        ],\n                    }),\n                ],\n                color: { domain: twoSeries, range: chartColors },\n                margin: 0,\n            },\n            {\n                focus: focusGroupAngle,\n                tooltip: {\n                    use: tooltip,\n                    motion: { type: \"spring\", stiffness: 170, damping: 18 },\n                    className: \"font-sans shadow-none rounded-md bg-popover text-popover-foreground border p-2 text-xs\",\n                    anchor: \"group-center\",\n                    placement: \"auto\",\n                    sort: \"color-domain\",\n                    content: (points) => shadcnTooltipContent(points),\n                },\n            },\n        );\n    }, [data]);\n\n    return (\n        <Card className=\"flex w-full max-w-md flex-col\">\n            <CardHeader className=\"items-center pb-4\">\n                <CardTitle>OWASP Security Risk Profile</CardTitle>\n                <CardDescription>Vulnerability posture rating across primary attack vectors</CardDescription>\n            </CardHeader>\n            <CardContent className=\"pb-0\">\n                <div className=\"mx-auto flex aspect-square max-h-[250px] w-full items-center justify-center\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        initialWidth={250}\n                        height={250}\n                        ariaLabel=\"OWASP Security Risk Profile Chart\"\n                    />\n                </div>\n            </CardContent>\n            <CardFooter className=\"flex-col gap-2 pt-4 text-sm\">\n                <div className=\"flex items-center gap-2 leading-none font-medium\">\n                    Security audit score improved by 5.2% this quarter{\" \"}\n                    <TrendingUp className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground flex items-center gap-2 leading-none\">January - June 2024</div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default RadarGridCircle;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. A radar chart with circular grid lines built with TanStack Charts. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "radar"
    ]
  }
}