{
  "title": "Surface Wind Directional Polar Scatter",
  "description": "2D polar coordinate distribution plotting wind speed and angle heading.",
  "name": "tanstack-charts-polar-scatter",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/line/polar-scatter.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { angleGrid, polar, 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 } from \"d3-scale\";\nimport { CircleDot } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface PolarWindDatum {\n    id: number;\n    direction: number;\n    speed: number;\n    station: string;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nconst angleDomain = [0, 360];\nconst radiusDomain = [0, 20];\nconst angleGridValues = [0, 45, 90, 135, 180, 225, 270, 315];\nconst radiusGridValues = [5, 10, 15, 20];\n\nfunction generateDemoData(): PolarWindDatum[] {\n    const results: PolarWindDatum[] = [];\n    for (let i = 0; i < 40; i++) {\n        const direction = Math.round(Math.random() * 360);\n        const speed = Number((3 + Math.random() * 15).toFixed(1));\n        results.push({\n            id: i,\n            direction,\n            speed,\n            station: `Station-${Math.floor(i / 10) + 1}`,\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 PolarWindDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: `${d.station} (Bearing: ${d.direction}°)`,\n        rows: [{ label: \"Wind Velocity\", value: `${d.speed} m/s`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function PolarScatterChart() {\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.76,\n                            scales: {\n                                angle: { scale: scaleLinear().domain(angleDomain) },\n                                radius: { scale: scaleLinear().domain(radiusDomain) },\n                            },\n                            guides: [\n                                radialGrid({\n                                    values: radiusGridValues,\n                                    labels: false,\n                                    stroke: \"var(--border)\",\n                                    strokeOpacity: 0.5,\n                                }),\n                                angleGrid({\n                                    values: angleGridValues,\n                                    labels: false,\n                                    stroke: \"var(--border)\",\n                                    strokeOpacity: 0.5,\n                                }),\n                            ],\n                            marks: [\n                                radialDot(data, {\n                                    id: \"polar-scatter-dots\",\n                                    angle: \"direction\",\n                                    radius: \"speed\",\n                                    r: 4.5,\n                                    fill: \"var(--chart-1)\",\n                                    stroke: \"var(--background)\",\n                                    strokeWidth: 1.5,\n                                }),\n                            ],\n                        }),\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>Surface Wind Directional Polar Scatter</CardTitle>\n                <CardDescription>\n                    2D polar coordinate distribution plotting wind bearings and speed observations\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=\"Surface Wind Directional Polar Scatter 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-station wind velocity readings plotted by bearing{\" \"}\n                    <CircleDot className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `radialDot` projects discrete observation points onto polar coordinate space\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default PolarScatterChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. 2D polar coordinate distribution plotting wind speed and angle heading. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "line"
    ]
  }
}