{
  "title": "Line Step",
  "description": "A step line chart displaying infrastructure capacity and active server counts built with TanStack Charts.",
  "name": "tanstack-charts-line-step",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-array",
    "d3-scale",
    "d3-shape"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/line/line-step.tsx",
      "type": "registry:block",
      "content": "import { defineChart, lineY } from \"@tanstack/charts\";\nimport { d3Curve } from \"@tanstack/charts/d3/shape\";\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 { max } from \"d3-array\";\nimport { scaleLinear, scalePoint } from \"d3-scale\";\nimport { curveStep } from \"d3-shape\";\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from \"@/components/ui/card\";\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nconst chartData = [\n    { month: \"January\", activeServers: 42 },\n    { month: \"February\", activeServers: 58 },\n    { month: \"March\", activeServers: 65 },\n    { month: \"April\", activeServers: 80 },\n    { month: \"May\", activeServers: 70 },\n    { month: \"June\", activeServers: 50 },\n    { month: \"July\", activeServers: 60 },\n    { month: \"August\", activeServers: 80 },\n    { month: \"September\", activeServers: 100 },\n];\n\nexport function LineStep() {\n    const definition = useMemo(() => {\n        const yMax = max(chartData, (d) => d.activeServers) ?? 0;\n\n        return defineChart({\n            renderer: motionRenderer,\n            motion: {\n                transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n            },\n            focus: \"group-x\",\n            tooltip: {\n                use: tooltip,\n                motion: { type: \"spring\", stiffness: 170, damping: 18 },\n                className: \"font-sans! shadow-none! capitalize!\",\n                content: (points) => {\n                    const datum = points[0]?.datum as (typeof chartData)[number];\n                    if (!datum) return { rows: [] };\n                    return {\n                        title: String(points[0].xValue),\n                        rows: [\n                            {\n                                label: \"Active Servers\",\n                                value: String(datum.activeServers),\n                                color: \"var(--chart-1)\",\n                            },\n                        ],\n                    };\n                },\n            },\n            marks: [\n                lineY(chartData, {\n                    id: \"activeServers\",\n                    x: (d) => d.month.slice(0, 3),\n                    y: (d) => d.activeServers,\n                    stroke: \"var(--chart-1)\",\n                    strokeWidth: 2,\n                    curve: d3Curve(curveStep),\n                    points: false,\n                }),\n            ],\n            scales: {\n                x: {\n                    scale: scalePoint().domain(chartData.map((d) => d.month.slice(0, 3))),\n                },\n                y: {\n                    scale: scaleLinear().domain([0, yMax]).nice(),\n                    grid: true,\n                },\n            },\n        });\n    }, []);\n\n    return (\n        <Card className=\"gap-4\">\n            <CardHeader>\n                <CardTitle className=\"text-lg\">Infrastructure Capacity</CardTitle>\n                <CardDescription>Active Instances (Q1–Q3 2024)</CardDescription>\n            </CardHeader>\n            <CardContent>\n                <Chart\n                    definition={definition}\n                    renderer={motionRenderer}\n                    height={250}\n                    ariaLabel=\"Step line chart showing active server count over time\"\n                />\n            </CardContent>\n        </Card>\n    );\n}\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. A step line chart displaying infrastructure capacity and active server counts built with TanStack Charts. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "line"
    ]
  }
}