{
  "title": "Temperature Range Band",
  "description": "Band area chart depicting high-low temperature range envelope.",
  "name": "tanstack-charts-temperature-range-band",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/area/temperature-range-band.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, areaY, defineChart, lineY } from \"@tanstack/charts\";\nimport { motion } from \"@tanstack/charts/motion\";\nimport { tooltip } from \"@tanstack/charts/tooltip\";\nimport { Chart } from \"@tanstack/react-charts/core\";\nimport { useMemo } from \"react\";\n\nimport { scaleLinear, scaleUtc } from \"d3-scale\";\nimport { Thermometer } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface TempDatum {\n    date: Date;\n    low: number;\n    high: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): TempDatum[] {\n    const baseDate = new Date(2025, 5, 1);\n    return Array.from({ length: 14 }, (_, i) => {\n        const d = new Date(baseDate);\n        d.setDate(baseDate.getDate() + i);\n        const low = 52 + Math.sin(i * 0.4) * 6 + (i % 3);\n        const high = low + 14 + Math.cos(i * 0.3) * 4;\n        return { date: d, low, high };\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 TempDatum;\n    if (!d) return { title: \"\", rows: [] };\n    const dateStr = d.date.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" });\n    return {\n        title: dateStr,\n        rows: [\n            { label: \"High\", value: `${d.high.toFixed(1)}°F`, color: \"var(--chart-1)\" },\n            { label: \"Low\", value: `${d.low.toFixed(1)}°F`, color: \"var(--chart-2)\" },\n        ],\n    };\n}\n\nexport function TemperatureRangeBand() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    marks: [\n                        areaY(data, {\n                            id: \"temp-band\",\n                            x: \"date\",\n                            y1: \"low\",\n                            y2: \"high\",\n                            fill: \"var(--chart-1)\",\n                            fillOpacity: 0.2,\n                        }),\n                        lineY(data, {\n                            id: \"temp-low\",\n                            x: \"date\",\n                            y: \"low\",\n                            stroke: \"var(--chart-2)\",\n                            strokeWidth: 2,\n                        }),\n                        lineY(data, {\n                            id: \"temp-high\",\n                            x: \"date\",\n                            y: \"high\",\n                            stroke: \"var(--chart-1)\",\n                            strokeWidth: 2,\n                        }),\n                    ],\n                    scales: {\n                        x: {\n                            scale: scaleUtc,\n                            axis: {\n                                line: false,\n                                label: \"Date\",\n                                ticks: {\n                                    size: 0,\n                                    padding: 10,\n                                    format: (d: Date) =>\n                                        d.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" }),\n                                },\n                            },\n                        },\n                        y: {\n                            scale: scaleLinear().domain([45, 80]),\n                            grid: true,\n                            axis: {\n                                line: false,\n                                label: \"Temperature (°F)\",\n                                ticks: { size: 0 },\n                            },\n                        },\n                    },\n                    margin: { top: 24, right: 24, bottom: 32, left: 40 },\n                    theme: {\n                        foreground: \"var(--muted-foreground)\",\n                        grid: \"var(--border)\",\n                        background: \"transparent\",\n                    },\n                },\n                {\n                    focus: \"group-x\",\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: \"group-center\",\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>Daily Temperature Range</CardTitle>\n                <CardDescription>Daily high and low ambient temperature band tracking</CardDescription>\n            </CardHeader>\n            <CardContent>\n                <div className=\"h-[250px] w-full\">\n                    <Chart\n                        definition={definition}\n                        renderer={motionRenderer}\n                        height={250}\n                        ariaLabel=\"Daily Temperature Range 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                    Average variance remains within 15°F range <Thermometer className=\"h-4 w-4 text-sky-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Shaded area represents temperature dispersion between min and max bounds\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default TemperatureRangeBand;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Band area chart depicting high-low temperature range envelope. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack"
    ]
  }
}