{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-sankey",
  "title": "Sankey Chart",
  "description": "Visitors from each source through the pages to sign-up, with a tooltip on every flow.",
  "dependencies": [
    "@wick-charts/react@^0.9.2"
  ],
  "registryDependencies": [
    "card",
    "https://wick-charts.eeff.io/r/wick-chart.json"
  ],
  "files": [
    {
      "path": "blocks/chart-sankey.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\n\nimport {\n  type SankeyLink,\n  type SankeyNode,\n  SankeySeries,\n  SankeyTooltip,\n} from \"@wick-charts/react\"\n\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\"\nimport { WickChart } from \"@/components/ui/wick-chart\"\n\nconst TICK_MS = 2000\n\nconst formatCount = (value: number) => Math.round(value).toLocaleString(\"en-US\")\n\nconst nodes: SankeyNode[] = [\n  { id: \"search\", label: \"Search\" },\n  { id: \"ads\", label: \"Paid ads\" },\n  { id: \"social\", label: \"Social\" },\n  { id: \"landing\", label: \"Landing page\" },\n  { id: \"blog\", label: \"Blog\" },\n  { id: \"signup\", label: \"Sign-up\" },\n  { id: \"bounced\", label: \"Bounced\" },\n]\n\nconst initialLinks: SankeyLink[] = [\n  { source: \"search\", target: \"landing\", value: 4200 },\n  { source: \"search\", target: \"blog\", value: 1800 },\n  { source: \"ads\", target: \"landing\", value: 2600 },\n  { source: \"social\", target: \"blog\", value: 1500 },\n  { source: \"social\", target: \"landing\", value: 600 },\n  { source: \"landing\", target: \"signup\", value: 2400 },\n  { source: \"landing\", target: \"bounced\", value: 5000 },\n  { source: \"blog\", target: \"signup\", value: 900 },\n  { source: \"blog\", target: \"bounced\", value: 2400 },\n]\n\n// Demo feed: every flow drifts by up to 5 % a tick.\nfunction driftLinks(links: SankeyLink[]): SankeyLink[] {\n  return links.map((link) => ({\n    ...link,\n    value: link.value * (1 + (Math.random() - 0.5) * 0.1),\n  }))\n}\n\nexport function ChartSankey() {\n  const [links, setLinks] = useState(initialLinks)\n\n  useEffect(() => {\n    const timer = setInterval(() => setLinks(driftLinks), TICK_MS)\n\n    return () => clearInterval(timer)\n  }, [])\n\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Visitor flow</CardTitle>\n        <CardDescription>From source to sign-up, last 30 days</CardDescription>\n      </CardHeader>\n      <CardContent>\n        <WickChart className=\"aspect-auto h-[300px]\">\n          <SankeySeries nodes={nodes} links={links} />\n          <SankeyTooltip format={formatCount} />\n        </WickChart>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "charts",
    "dashboard"
  ],
  "type": "registry:block"
}