{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-delivery-capacity",
  "title": "Delivery capacity",
  "author": "andongmin94",
  "description": "Planned and delivered work with team controls, signed variance, and exact 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-delivery-capacity.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { Bar, BarChart, CartesianGrid, ReferenceLine, XAxis, YAxis } 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 teams = {\n  Product: [\n    [32, 28],\n    [36, 39],\n    [34, 31],\n    [38, 42],\n  ],\n  Platform: [\n    [24, 26],\n    [28, 23],\n    [26, 29],\n    [30, 30],\n  ],\n} as const;\nconst config = {\n  planned: { label: \"Planned\", color: \"var(--secondary-background)\" },\n  delivered: { label: \"Delivered\", color: \"var(--chart-1)\" },\n  variance: { label: \"Delivered minus planned\", color: \"var(--chart-2)\" },\n} satisfies ChartConfig;\nconst signed = (value: number) => `${value > 0 ? \"+\" : \"\"}${value}`;\n\nexport default function ChartDeliveryCapacity() {\n  const [team, setTeam] = useState<keyof typeof teams>(\"Product\");\n  const [view, setView] = useState(\"compare\");\n  const data = teams[team].map(([planned, delivered], index) => ({\n    sprint: `S${index + 1}`,\n    planned,\n    delivered,\n    variance: delivered - planned,\n  }));\n  const planned = data.reduce((total, row) => total + row.planned, 0);\n  const delivered = data.reduce((total, row) => total + row.delivered, 0);\n  const metPlan = data.filter((row) => row.variance >= 0).length;\n  const variance = view === \"variance\";\n\n  return (\n    <Card className=\"min-w-0\" data-chart-recipe=\"capacity\">\n      <CardHeader>\n        <p className=\"font-mono text-xs uppercase tracking-widest\">\n          Delivery / Compare against a plan\n        </p>\n        <CardTitle>\n          <h3>Delivery capacity</h3>\n        </CardTitle>\n        <CardDescription>\n          Planned and completed work in illustrative item counts. Not a team productivity score.\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=\"Delivery team\"\n            value={team}\n            onValueChange={(value) => setTeam(value as keyof typeof teams)}\n            options={Object.keys(teams).map((value) => ({ value, label: value }))}\n          />\n          <ChartSelect\n            label=\"Delivery view\"\n            value={view}\n            onValueChange={setView}\n            options={[\n              { value: \"compare\", label: \"Planned and delivered\" },\n              { value: \"variance\", label: \"Signed variance\" },\n            ]}\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            [\"Planned items\", planned],\n            [\"Delivered items\", delivered],\n            [\"Net variance\", signed(delivered - planned)],\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\n          aria-label={\n            variance\n              ? \"Signed delivery variance by sprint\"\n              : \"Planned and delivered items by sprint\"\n          }\n          className=\"min-w-0\"\n        >\n          <ChartContainer config={config} className=\"h-72 w-full min-w-0 aspect-auto\">\n            <BarChart\n              accessibilityLayer\n              data={data}\n              margin={{ top: 12, right: 12, left: 0, bottom: 0 }}\n            >\n              <CartesianGrid vertical={false} />\n              <XAxis dataKey=\"sprint\" tickLine={false} axisLine={false} tickMargin={10} />\n              <YAxis\n                width={40}\n                domain={variance ? [-8, 8] : [0, 48]}\n                tickLine={false}\n                axisLine={false}\n                allowDecimals={false}\n              />\n              <ReferenceLine y={0} stroke=\"var(--foreground)\" strokeWidth={2} />\n              <ChartTooltip\n                content={\n                  <ChartTooltipContent\n                    formatter={(value, name) =>\n                      `${config[name as keyof typeof config]?.label ?? name}: ${Number(value)} items`\n                    }\n                  />\n                }\n              />\n              {variance ? (\n                <Bar\n                  dataKey=\"variance\"\n                  fill=\"var(--color-variance)\"\n                  stroke=\"var(--foreground)\"\n                  strokeWidth={2}\n                  maxBarSize={48}\n                  isAnimationActive={false}\n                />\n              ) : (\n                <>\n                  <Bar\n                    dataKey=\"planned\"\n                    fill=\"var(--color-planned)\"\n                    stroke=\"var(--foreground)\"\n                    strokeWidth={2}\n                    strokeDasharray=\"4 3\"\n                    maxBarSize={40}\n                    isAnimationActive={false}\n                  />\n                  <Bar\n                    dataKey=\"delivered\"\n                    fill=\"var(--color-delivered)\"\n                    stroke=\"var(--foreground)\"\n                    strokeWidth={2}\n                    maxBarSize={40}\n                    isAnimationActive={false}\n                  />\n                </>\n              )}\n            </BarChart>\n          </ChartContainer>\n          <figcaption className=\"mt-3 text-xs leading-5\">\n            {variance\n              ? \"Above zero: more items delivered than planned. Below zero: fewer.\"\n              : \"Outlined / dashed: planned. Filled / solid: delivered. Both start at zero.\"}\n          </figcaption>\n        </figure>\n        <output className=\"border-l-4 border-main pl-3 text-sm leading-6\">\n          {metPlan} of {data.length} sprints met or exceeded plan. The variance is delivered minus\n          planned, not a percentage.\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 delivery data</summary>\n          <table className=\"mt-3 w-full text-left text-xs tabular-nums\">\n            <caption className=\"pb-3 text-left\">\n              {team}. Item counts for the same four sprints.\n            </caption>\n            <thead>\n              <tr>\n                {[\"Sprint\", \"Planned\", \"Delivered\", \"Variance\"].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.sprint}>\n                  <th scope=\"row\" className=\"py-3 pr-2\">\n                    {row.sprint}\n                  </th>\n                  <td>{row.planned}</td>\n                  <td>{row.delivered}</td>\n                  <td>{signed(row.variance)}</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"
}