{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-work-allocation",
  "title": "Work allocation",
  "author": "andongmin94",
  "description": "Planned hours with period controls, a workstream inspector, and part-to-whole values.",
  "dependencies": [
    "recharts@^3.10.1"
  ],
  "registryDependencies": [
    "https://neobrutal-ui.andongmin.com/r/chart.json",
    "https://neobrutal-ui.andongmin.com/r/card.json"
  ],
  "files": [
    {
      "path": "src/components/ui/chart-work-allocation.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Pie, PieChart } from \"recharts\";\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport {\n  ChartContainer,\n  ChartSelect,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\";\n\nconst periods = {\n  Current: [48, 72, 36, 24],\n  Next: [36, 90, 54, 30],\n} as const;\nconst workstreams = [\"Design\", \"Build\", \"Test\", \"Operations\"];\nconst config = {\n  hours: { label: \"Hours\" },\n  Design: { label: \"Design\", color: \"var(--chart-1)\" },\n  Build: { label: \"Build\", color: \"var(--chart-2)\" },\n  Test: { label: \"Test\", color: \"var(--chart-3)\" },\n  Operations: { label: \"Operations\", color: \"var(--chart-4)\" },\n} satisfies ChartConfig;\n\nexport default function ChartWorkAllocation() {\n  const [period, setPeriod] = useState<keyof typeof periods>(\"Current\");\n  const [selected, setSelected] = useState(\"Design\");\n  const data = workstreams.map((work, index) => ({\n    work,\n    hours: periods[period][index],\n    fill: `var(--color-${work})`,\n  }));\n  const total = data.reduce((sum, row) => sum + row.hours, 0);\n  const selectedRow = data.find((row) => row.work === selected)!;\n\n  return (\n    <Card className=\"min-w-0\" data-chart-recipe=\"allocation\">\n      <CardHeader>\n        <p className=\"font-mono text-xs uppercase tracking-widest\">\n          Allocation / Read the whole and its parts\n        </p>\n        <CardTitle>\n          <h3>Work allocation</h3>\n        </CardTitle>\n        <CardDescription>\n          Planned hours across four workstreams. Illustrative planning data, not tracked time.\n        </CardDescription>\n      </CardHeader>\n      <CardContent className=\"grid min-w-0 gap-6\">\n        <div className=\"flex flex-wrap gap-4\">\n          <ChartSelect\n            label=\"Allocation period\"\n            value={period}\n            onValueChange={(value) => setPeriod(value as keyof typeof periods)}\n            options={Object.keys(periods).map((value) => ({ value, label: value }))}\n          />\n          <ChartSelect\n            label=\"Inspect workstream\"\n            value={selected}\n            onValueChange={setSelected}\n            options={workstreams.map((value) => ({ value, label: value }))}\n          />\n        </div>\n        <dl className=\"grid gap-4 border-y-2 border-border py-4 sm:grid-cols-3\" aria-live=\"polite\">\n          {[\n            [\"Total planned\", `${total} h`],\n            [selected, `${selectedRow.hours} h`],\n            [\"Share of total\", `${((selectedRow.hours / total) * 100).toFixed(1)}%`],\n          ].map(([label, value]) => (\n            <div key={label}>\n              <dt className=\"text-xs\">{label}</dt>\n              <dd className=\"mt-1 text-2xl font-heading tabular-nums\">{value}</dd>\n            </div>\n          ))}\n        </dl>\n        <figure aria-label=\"Planned hours by workstream\" className=\"min-w-0\">\n          <ChartContainer\n            config={config}\n            className=\"mx-auto h-72 w-full max-w-md min-w-0 aspect-auto\"\n          >\n            <PieChart accessibilityLayer>\n              <ChartTooltip\n                content={\n                  <ChartTooltipContent\n                    nameKey=\"work\"\n                    hideLabel\n                    formatter={(value, _name, item) => `${item.payload.work}: ${value} h`}\n                  />\n                }\n              />\n              <Pie\n                data={data}\n                dataKey=\"hours\"\n                nameKey=\"work\"\n                startAngle={0}\n                endAngle={-360}\n                innerRadius=\"55%\"\n                outerRadius=\"85%\"\n                paddingAngle={3}\n                stroke=\"var(--border)\"\n                strokeWidth={2}\n                isAnimationActive={false}\n              />\n            </PieChart>\n          </ChartContainer>\n          <figcaption className=\"mt-3 text-xs leading-5\">\n            Clockwise from the right: Design, Build, Test, Operations. Use the inspector or table\n            for exact values without relying on color.\n          </figcaption>\n        </figure>\n        <output className=\"border-l-4 border-main pl-3 text-sm leading-6\">\n          {selected} accounts for {selectedRow.hours} of {total} planned hours. Changing the\n          inspector does not remove other workstreams from the total.\n        </output>\n        <details className=\"min-w-0 border-t-2 border-border pt-4\">\n          <summary className=\"cursor-pointer text-sm font-heading\">View allocation data</summary>\n          <table className=\"mt-3 w-full text-left text-xs tabular-nums\">\n            <caption className=\"pb-3 text-left\">\n              {period} period. Shares use the total of all four workstreams.\n            </caption>\n            <thead>\n              <tr>\n                {[\"Workstream\", \"Hours\", \"Share\"].map((label) => (\n                  <th key={label} scope=\"col\" className=\"border-b-2 border-border py-2 pr-2\">\n                    {label}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {data.map((row) => (\n                <tr key={row.work} className={selected === row.work ? \"bg-background\" : undefined}>\n                  <th scope=\"row\" className=\"py-3 pr-2\">\n                    {row.work}\n                    {selected === row.work && <span className=\"sr-only\">, selected</span>}\n                  </th>\n                  <td>{row.hours}</td>\n                  <td>{((row.hours / total) * 100).toFixed(1)}%</td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </details>\n      </CardContent>\n    </Card>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "data-display",
    "data-visualization",
    "recipe"
  ],
  "type": "registry:component"
}