{
  "title": "Waffle Unit Chart",
  "description": "Square cell unit grid visualizing proportion and volume.",
  "name": "tanstack-charts-waffle-unit-chart",
  "dependencies": [
    "@tanstack/charts",
    "@tanstack/react-charts"
  ],
  "registryDependencies": [
    "card"
  ],
  "type": "registry:block",
  "files": [
    {
      "path": "components/blocks/tanstack-charts/bar/waffle-unit-chart.tsx",
      "type": "registry:block",
      "content": "import { type ChartPoint, defineChart, waffleY } 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 { Grid3X3 } from \"lucide-react\";\n\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface WaffleDatum {\n    category: string;\n    value: number;\n}\n\nconst motionRenderer = motion({\n    initial: \"always\",\n    transition: { type: \"spring\", stiffness: 170, damping: 18, mass: 1 },\n});\n\nfunction generateDemoData(): WaffleDatum[] {\n    return [\n        { category: \"React\", value: 35 },\n        { category: \"Vue\", value: 25 },\n        { category: \"Svelte\", value: 20 },\n        { category: \"Angular\", value: 12 },\n        { category: \"Solid\", value: 8 },\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 WaffleDatum;\n    if (!d) return { title: \"\", rows: [] };\n    return {\n        title: d.category,\n        rows: [{ label: \"Share Percentage\", value: `${d.value}%`, color: \"var(--chart-1)\" }],\n    };\n}\n\nexport function WaffleUnitChart() {\n    const data = useMemo(() => generateDemoData(), []);\n\n    const definition = useMemo(\n        () =>\n            defineChart(\n                {\n                    renderer: motionRenderer,\n                    scales: {\n                        x: null,\n                        y: null,\n                    },\n                    marks: [\n                        waffleY(data, {\n                            y: \"value\",\n                            color: \"category\",\n                            key: \"category\",\n                            unit: 1,\n                            gap: 2,\n                            round: true,\n                            radius: 3,\n                        }),\n                    ],\n                    guides: false,\n                    color: {\n                        domain: data.map((d) => d.category),\n                        range: [\n                            \"var(--chart-1)\",\n                            \"var(--chart-2)\",\n                            \"var(--chart-3)\",\n                            \"var(--chart-4)\",\n                            \"var(--chart-5)\",\n                        ],\n                    },\n                    margin: { top: 24, right: 24, bottom: 24, left: 24 },\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>Frontend Framework Market Share Waffle</CardTitle>\n                <CardDescription>100-cell unit square grid representing proportion breakdown</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=\"Frontend Framework Market Share Waffle 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                    React and Vue account for 60% of overall developer usage{\" \"}\n                    <Grid3X3 className=\"h-4 w-4 text-emerald-500\" />\n                </div>\n                <div className=\"text-muted-foreground leading-none\">\n                    Each rounded grid unit square represents 1% market allocation\n                </div>\n            </CardFooter>\n        </Card>\n    );\n}\n\nexport default WaffleUnitChart;\n"
    }
  ],
  "mcp": {
    "description": "Renders responsive data visualization with dark mode styling and customizable tooltips. Square cell unit grid visualizing proportion and volume. Relies on card. Use when presenting data insights or analytics dashboards.",
    "tags": [
      "chart",
      "tanstack"
    ]
  }
}