{
  "title": "Line Chart Dots",
  "description": "A line chart displaying data point dots built with TanStack Charts.",
  "name": "tanstack-charts-line-dots",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale",
    "d3-shape"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/line/line-chart-dots.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, d3Curve, defineChart, dot, 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, scalePoint } from \"d3-scale\";\nimport { curveNatural } from \"d3-shape\";\nimport { TrendingUp } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface MonthDatum {\n    month: string;\n    desktop: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): MonthDatum[] {\n    return [\n        { month: \"January\", desktop: 186 },\n        { month: \"February\", desktop: 305 },\n        { month: \"March\", desktop: 237 },\n        { month: \"April\", desktop: 73 },\n        { month: \"May\", desktop: 209 },\n        { month: \"June\", desktop: 214 },\n    ];\n}\n\nfunction titleCase(value: string) {\n    return value.charAt(0).toUpperCase() + value.slice(1);\n}\n\nfunction shadcnTooltipContent<TDatum>(points: readonly ChartPoint<TDatum>[]) {\n    return {\n        title: String(points[0]?.xValue ?? \"\"),\n        rows: points.map((point) => ({\n            label: titleCase(\n                String(point.group ?? point.markId.replace(/-?(bars|lines|areas|slices|values|radar)$/u, \"\")),\n            ),\n            value: Number(point.yValue ?? point.xValue ?? 0).toLocaleString(\"en-US\"),\n            color: point.color,\n        })),\n    };\n}\n\nexport function LineChartDots() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    motion: {\n                        transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n                    },\n                    marks: [\n                        lineY(data, {\n                            id: \"visitor-line\",\n                            x: \"month\",\n                            y: \"desktop\",\n                            curve: d3Curve(curveNatural),\n                            stroke: \"var(--chart-1)\",\n                            strokeWidth: 2,\n                        }),\n                        dot(data, {\n                            id: \"visitor-dots\",\n                            x: \"month\",\n                            y: \"desktop\",\n                            r: 4,\n                            fill: \"var(--chart-1)\",\n                            stroke: \"var(--chart-1)\",\n                            strokeWidth: 1,\n                        }),\n                    ],\n                    scales: {\n                        x: {\n                            scale: scalePoint,\n                            axis: {\n                                line: false,\n                                ticks: {\n                                    size: 0,\n                                    padding: 10,\n                                    format: (value: string) => value.slice(0, 3),\n                                },\n                            },\n                        },\n                        y: {\n                            scale: scaleLinear().domain([0, 320]),\n                            grid: true,\n                            axis: {\n                                line: false,\n                                ticks: {\n                                    values: [0, 80, 160, 240, 320],\n                                    size: 0,\n                                },\n                                tickLabels: false,\n                            },\n                        },\n                    },\n                    color: {\n                        domain: [\"desktop\"],\n                        range: [\"var(--chart-1)\"],\n                    },\n                    margin: {\n                        top: 8,\n                        right: 12,\n                        bottom: 35,\n                        left: 12,\n                    },\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                        motion: { type: \"spring\", stiffness: 170, damping: 18 },\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                        sort: \"color-domain\",\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>System Memory Utilization</CardTitle>\n                <CardDescription>RAM usage percentage across production server nodes</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=\"System Memory Utilization 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                    Memory efficiency optimized by 5.2% this month <TrendingUp className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">Showing total visitors for the last 6 months</div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default LineChartDots;\n"
    }
  ],
  "mcp": {
    "description": "A line chart displaying data point dots built with TanStack Charts. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "line"
    ]
  }
}