{
  "title": "Many Point Scatter",
  "description": "High-density multivariate bubble scatterplot encoding weight, economy, and power.",
  "name": "tanstack-charts-many-point-scatter",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts",
    "d3-scale"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/line/many-point-scatter.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart, dot } 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, scaleSqrt } from \"d3-scale\";\nimport { ScatterChart } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface HighDensityDatum {\n    name: string;\n    weight: number;\n    acceleration: number;\n    cylinders: number;\n    displacement: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): HighDensityDatum[] {\n    const results: HighDensityDatum[] = [];\n    const models = [\"Sedan\", \"Coupe\", \"SUV\", \"Truck\", \"Hatchback\"];\n\n    for (let i = 0; i < 180; i++) {\n        const weight = 1800 + Math.random() * 3200;\n        const acceleration = 22 - (weight - 1800) * 0.003 + (Math.random() - 0.5) * 5;\n        const cylinders = [4, 6, 8][i % 3];\n        const displacement = 1200 + cylinders * 400 + Math.random() * 800;\n        results.push({\n            name: `${models[i % models.length]} ${2015 + (i % 10)} #${i + 1}`,\n            weight: Math.round(weight),\n            acceleration: Number(Math.max(8, acceleration).toFixed(1)),\n            cylinders,\n            displacement: Math.round(displacement),\n        });\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 HighDensityDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.name,\n        rows: [\n            { label: \"Weight\", value: `${d.weight.toLocaleString()} lb`, color: \"var(--chart-1)\" },\n            { label: \"0-60mph Time\", value: `${d.acceleration}s`, color: \"var(--chart-2)\" },\n            { label: \"Engine Displacement\", value: `${d.displacement} cc`, color: \"var(--foreground)\" },\n        ],\n    };\n}\n\nexport function ManyPointScatter() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    marks: [\n                        dot(data, {\n                            id: \"cars\",\n                            x: \"weight\",\n                            y: \"acceleration\",\n                            color: (r: HighDensityDatum) => `${r.cylinders}`,\n                            key: \"name\",\n                            r: \"displacement\",\n                            rScale: {\n                                scale: () => scaleSqrt().range([2.5, 6]),\n                            },\n                            fillOpacity: 0.7,\n                            stroke: \"var(--background)\",\n                            strokeWidth: 0.5,\n                        }),\n                    ],\n                    scales: {\n                        x: { scale: scaleLinear, grid: true, axis: { label: \"Vehicle Weight (lb)\" } },\n                        y: { scale: scaleLinear, grid: true, axis: { label: \"0-60 mph Acceleration (sec)\" } },\n                    },\n                    color: {\n                        range: [\"var(--chart-1)\", \"var(--chart-2)\", \"var(--chart-3)\"],\n                    },\n                    margin: { top: 24, right: 24, bottom: 32, left: 45 },\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>High-Density Multivariate Bubble Scatterplot</CardTitle>\n                <CardDescription>\n                    Large point-count scatterplot encoding weight, acceleration, cylinder count, and engine displacement\n                </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=\"High-Density Multivariate Bubble Scatterplot 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                    Bubble area scales with square-root engine displacement{\" \"}\n                    <ScatterChart className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Supports high point count rendering with custom radius and color encoding\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default ManyPointScatter;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. High-density multivariate bubble scatterplot encoding weight, economy, and power. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack",
      "line"
    ]
  }
}