{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "analytics-07",
  "type": "registry:block",
  "description": "Interactive stacked bar chart of signups by channel with toggleable legend chips and hover-to-inspect weekly totals.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/designali/blocks/analytics/analytics-07.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\n\nimport { cn } from \"@workspace/ui/lib/utils\"\n\nconst channels = [\n  { key: \"organic\", label: \"Search\", color: \"var(--chart-1)\" },\n  { key: \"paid\", label: \"Social\", color: \"var(--chart-2)\" },\n  { key: \"partner\", label: \"21st.dev\", color: \"var(--chart-3)\" },\n] as const\n\ntype ChannelKey = (typeof channels)[number][\"key\"]\n\nconst weeks: { week: string; organic: number; paid: number; partner: number }[] = [\n  { week: \"W35\", organic: 420, paid: 210, partner: 90 },\n  { week: \"W36\", organic: 450, paid: 240, partner: 110 },\n  { week: \"W37\", organic: 430, paid: 280, partner: 100 },\n  { week: \"W38\", organic: 480, paid: 260, partner: 130 },\n  { week: \"W39\", organic: 510, paid: 300, partner: 120 },\n  { week: \"W40\", organic: 540, paid: 320, partner: 150 },\n  { week: \"W41\", organic: 520, paid: 290, partner: 170 },\n  { week: \"W42\", organic: 580, paid: 340, partner: 160 },\n  { week: \"W43\", organic: 610, paid: 360, partner: 190 },\n  { week: \"W44\", organic: 640, paid: 330, partner: 210 },\n  { week: \"W45\", organic: 690, paid: 380, partner: 220 },\n  { week: \"W46\", organic: 720, paid: 410, partner: 240 },\n]\n\nexport default function Analytics07() {\n  const [enabled, setEnabled] = useState<ChannelKey[]>([\"organic\", \"paid\", \"partner\"])\n  const [hover, setHover] = useState<number | null>(null)\n\n  const totals = weeks.map((w) => enabled.reduce((sum, k) => sum + w[k], 0))\n  const max = Math.max(...totals, 1)\n  const active = hover !== null ? weeks[hover] : undefined\n\n  function toggle(key: ChannelKey) {\n    setEnabled((prev) =>\n      prev.includes(key)\n        ? prev.length > 1\n          ? prev.filter((k) => k !== key)\n          : prev\n        : [...prev, key]\n    )\n  }\n\n  return (\n    <section className=\"w-full bg-background py-16 text-foreground md:py-24\">\n      <div className=\"mx-auto max-w-7xl px-6\">\n        <div className=\"border bg-card p-6 md:p-8\">\n          <div className=\"flex flex-col gap-6 md:flex-row md:items-start md:justify-between\">\n            <div>\n              <p className=\"text-sm text-muted-foreground\">designali.com signups by channel</p>\n              <p className=\"mt-1 text-3xl font-semibold tracking-tight\">\n                {(active\n                  ? enabled.reduce((s, k) => s + active[k], 0)\n                  : totals.reduce((s, v) => s + v, 0)\n                ).toLocaleString()}\n              </p>\n              <p className=\"mt-1 text-xs text-muted-foreground\">\n                {active ? `Week ${active.week.slice(1)}` : \"Total, last 12 weeks\"}\n              </p>\n            </div>\n            <div className=\"flex flex-wrap gap-2\">\n              {channels.map((c) => {\n                const on = enabled.includes(c.key)\n                return (\n                  <button\n                    key={c.key}\n                    type=\"button\"\n                    onClick={() => toggle(c.key)}\n                    aria-pressed={on}\n                    className={cn(\n                      \"inline-flex items-center gap-2 border px-3 py-1.5 text-xs transition-colors\",\n                      on ? \"bg-background text-foreground\" : \"text-muted-foreground opacity-60\"\n                    )}\n                  >\n                    <span className=\"size-2.5\" style={{ background: c.color }} />\n                    {c.label}\n                  </button>\n                )\n              })}\n            </div>\n          </div>\n\n          <div\n            className=\"relative mt-10 flex h-64 items-end gap-1.5 sm:gap-3\"\n            onMouseLeave={() => setHover(null)}\n          >\n            <div className=\"pointer-events-none absolute inset-0 flex flex-col justify-between\">\n              {[0, 1, 2, 3, 4].map((i) => (\n                <div key={i} className=\"border-t border-dashed border-border\" />\n              ))}\n            </div>\n            {weeks.map((w, i) => (\n              <div\n                key={w.week}\n                onMouseEnter={() => setHover(i)}\n                className={cn(\n                  \"relative flex h-full flex-1 flex-col justify-end transition-opacity\",\n                  hover !== null && hover !== i && \"opacity-40\"\n                )}\n              >\n                {channels\n                  .filter((c) => enabled.includes(c.key))\n                  .map((c) => (\n                    <div\n                      key={c.key}\n                      style={{ height: `${(w[c.key] / max) * 100}%`, background: c.color }}\n                      className=\"w-full transition-[height] duration-300\"\n                    />\n                  ))}\n              </div>\n            ))}\n          </div>\n          <div className=\"mt-3 flex gap-1.5 text-center text-[10px] text-muted-foreground sm:gap-3\">\n            {weeks.map((w, i) => (\n              <span key={w.week} className={cn(\"flex-1\", i % 2 === 1 && \"hidden sm:block\")}>\n                {w.week}\n              </span>\n            ))}\n          </div>\n\n          <div className=\"mt-8 grid grid-cols-3 border-t pt-6\">\n            {channels.map((c) => (\n              <div key={c.key}>\n                <p className=\"text-xs text-muted-foreground\">{c.label}</p>\n                <p className=\"mt-1 text-lg font-medium\">\n                  {(active ? active[c.key] : weeks.reduce((s, w) => s + w[c.key], 0)).toLocaleString()}\n                </p>\n              </div>\n            ))}\n          </div>\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "750px"
  },
  "categories": [
    "analytics"
  ]
}