{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-area-stacked",
  "title": "Stacked Area Chart",
  "description": "Two series stacked over three months, with a tooltip and a legend that toggles them.",
  "dependencies": [
    "@wick-charts/react@^0.9.2"
  ],
  "registryDependencies": [
    "card",
    "https://wick-charts.eeff.io/r/wick-chart.json"
  ],
  "files": [
    {
      "path": "blocks/chart-area-stacked.tsx",
      "content": "\"use client\"\n\nimport {\n  Crosshair,\n  Legend,\n  LineSeries,\n  TimeAxis,\n  type TimePoint,\n  Tooltip,\n  YAxis,\n} from \"@wick-charts/react\"\n\nimport {\n  Card,\n  CardAction,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\"\nimport { WickChart } from \"@/components/ui/wick-chart\"\n\nconst DAY_MS = 86_400_000\nconst DAYS = 90\n\nconst formatCount = (value: number) => Math.round(value).toLocaleString(\"en-US\")\n\nconst areaOptions = { stacking: \"normal\" as const, pulse: false }\n\n// Seeded, so the server render and the browser show the same total.\nfunction seededRandom(seed: number): () => number {\n  let state = seed\n\n  return () => {\n    state = (state * 1_664_525 + 1_013_904_223) % 4_294_967_296\n\n    return state / 4_294_967_296\n  }\n}\n\n// Demo data: daily visitors with a weekly rhythm. Replace with your own series.\nfunction makeVisitors(): { desktop: TimePoint[]; mobile: TimePoint[] } {\n  const random = seededRandom(3)\n  const start = Math.floor(Date.now() / DAY_MS) * DAY_MS - DAYS * DAY_MS\n  const desktop: TimePoint[] = []\n  const mobile: TimePoint[] = []\n\n  for (let day = 0; day < DAYS; day++) {\n    const time = start + day * DAY_MS\n    const weekly = Math.sin((day / 7) * Math.PI * 2) * 40\n    desktop.push({\n      time,\n      value: Math.round(220 + weekly + day * 1.2 + random() * 80),\n    })\n    mobile.push({\n      time,\n      value: Math.round(160 - weekly * 0.6 + day * 0.8 + random() * 60),\n    })\n  }\n\n  return { desktop, mobile }\n}\n\nconst visitors = makeVisitors()\n// The first layer sits at the bottom of the stack.\nconst series = [\n  { label: \"Mobile\", data: visitors.mobile },\n  { label: \"Desktop\", data: visitors.desktop },\n]\nconst total = series.reduce(\n  (sum, layer) =>\n    sum + layer.data.reduce((layerSum, point) => layerSum + point.value, 0),\n  0\n)\n\nexport function ChartAreaStacked() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Visitors</CardTitle>\n        <CardDescription>Desktop and mobile, last 3 months</CardDescription>\n        <CardAction className=\"text-right\">\n          <div className=\"text-2xl font-semibold tabular-nums\">\n            {formatCount(total)}\n          </div>\n          <div className=\"text-xs text-muted-foreground\">total</div>\n        </CardAction>\n      </CardHeader>\n      <CardContent>\n        <WickChart className=\"aspect-auto h-[280px]\">\n          <LineSeries data={series} options={areaOptions} />\n          <YAxis format={formatCount} />\n          <TimeAxis />\n          <Crosshair />\n          <Tooltip format={formatCount} />\n          <Legend />\n        </WickChart>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "charts",
    "dashboard"
  ],
  "type": "registry:block"
}