{
  "title": "Interval Timeline",
  "description": "Gantt-style timeline chart mapping continuous interval event ranges.",
  "name": "tanstack-charts-interval-timeline",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/bar/interval-timeline.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, barX, defineChart } 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 { scaleBand, scaleLinear } from \"d3-scale\";\nimport { Activity } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface RangeDatum {\n    task: string;\n    start: number;\n    end: number;\n    status: string;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): RangeDatum[] {\n    return [\n        { task: \"Design System\", start: 10, end: 35, status: \"Complete\" },\n        { task: \"API Gateway\", start: 25, end: 60, status: \"Complete\" },\n        { task: \"Auth Service\", start: 40, end: 80, status: \"In Progress\" },\n        { task: \"Dashboard UI\", start: 55, end: 95, status: \"In Progress\" },\n        { task: \"Deploy Pipeline\", start: 75, end: 120, status: \"Pending\" },\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 RangeDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.task,\n        rows: [\n            { label: \"Status\", value: d.status, color: points[0].color || \"var(--chart-1)\" },\n            { label: \"Duration\", value: `${d.start} - ${d.end} days`, color: \"var(--foreground)\" },\n        ],\n    };\n}\n\nexport function IntervalTimeline() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    marks: [\n                        barX(data, {\n                            id: \"interval-bars\",\n                            x1: \"start\",\n                            x2: \"end\",\n                            y: \"task\",\n                            color: \"status\",\n                            inset: 2,\n                            radius: 4,\n                        }),\n                    ],\n                    scales: {\n                        x: {\n                            scale: scaleLinear().domain([0, 140]),\n                            grid: true,\n                            axis: {\n                                line: false,\n                                label: \"Timeline (Days)\",\n                                ticks: { size: 0 },\n                            },\n                        },\n                        y: {\n                            scale: () => scaleBand<string>().paddingInner(0.25),\n                            axis: {\n                                line: false,\n                                ticks: { size: 0 },\n                            },\n                        },\n                    },\n                    color: {\n                        domain: [\"Complete\", \"In Progress\", \"Pending\"],\n                        range: [\"var(--chart-1)\", \"var(--chart-2)\", \"var(--chart-3)\"],\n                    },\n                    margin: { top: 24, right: 24, bottom: 32, left: 100 },\n                    theme: {\n                        foreground: \"var(--muted-foreground)\",\n                        grid: \"var(--border)\",\n                        background: \"transparent\",\n                    },\n                },\n                {\n                    focus: \"group-y\",\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>Project Phase Schedule</CardTitle>\n                <CardDescription>Horizontal interval timeline tracking initiative milestone ranges</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=\"Project Phase Schedule 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                    4 out of 5 core tasks progressing on schedule <Activity className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Bar start and end positions delineate task interval start and target completion dates\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default IntervalTimeline;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Gantt-style timeline chart mapping continuous interval event ranges. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack"
    ]
  }
}