{
  "title": "Seasonal Annual Polar Line Cycle",
  "description": "Continuous 360-degree cyclical temperature polar chart.",
  "name": "tanstack-charts-polar-line",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/line/polar-line.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { angleGrid, polar, radialGrid, radialLine } 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 { Compass } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface PolarWeatherDatum {\n    dayOfYear: number;\n    angle: number;\n    tempMax: number;\n    date: Date;\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 = [-10, 40];\nconst angleGridValues = [0, 45, 90, 135, 180, 225, 270, 315];\nconst radiusGridValues = [0, 10, 20, 30, 40];\n\nfunction generateDemoData(): PolarWeatherDatum[] {\n    const results: PolarWeatherDatum[] = [];\n    const baseDate = new Date(Date.UTC(2024, 0, 1)).getTime();\n\n    for (let day = 0; day < 365; day += 5) {\n        const angle = (day / 365) * 360;\n        const seasonal = 15 + 18 * Math.sin(((day - 80) / 365) * 2 * Math.PI);\n        const noise = (Math.random() - 0.5) * 6;\n        const tempMax = Number(Math.max(-5, seasonal + noise).toFixed(1));\n        results.push({\n            dayOfYear: day,\n            angle,\n            tempMax,\n            date: new Date(baseDate + day * 24 * 60 * 60 * 1000),\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 PolarWeatherDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.date.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\", timeZone: \"UTC\" }),\n        rows: [{ label: \"Daily High Temp\", value: `${d.tempMax}°C`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function PolarLineChart() {\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                                radialLine(data, {\n                                    id: \"polar-line-series\",\n                                    angle: \"angle\",\n                                    radius: \"tempMax\",\n                                    stroke: \"var(--chart-1)\",\n                                    strokeWidth: 2,\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>Seasonal Annual Polar Line Cycle</CardTitle>\n                <CardDescription>\n                    Continuous 360-degree cyclical temperature line mapping days of the year to angles\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=\"Seasonal Annual Polar Line Cycle 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                    Cyclical 365-day annual temperature curve in polar space{\" \"}\n                    <Compass className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    `radialLine` projects continuous temporal sequences around circular origin\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default PolarLineChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Continuous 360-degree cyclical temperature polar chart. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "line"
    ]
  }
}