{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-pie-occupancy",
  "title": "Bed occupancy pie chart",
  "description": "Bed occupancy, as a donut chart with the total.",
  "dependencies": [
    "recharts@^3.8.0"
  ],
  "registryDependencies": [
    "card",
    "chart"
  ],
  "files": [
    {
      "path": "registry/base-nova/charts/chart-pie-occupancy.tsx",
      "content": "\"use client\"\n\nimport { Label, Pie, PieChart } from \"recharts\"\n\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\"\nimport {\n  ChartContainer,\n  ChartLegend,\n  ChartLegendContent,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\"\n\nexport const description = \"Bed occupancy, as a donut chart with the total\"\n\n// Beds right now, illustrative.\nconst chartData = [\n  { status: \"occupied\", beds: 312, fill: \"var(--color-occupied)\" },\n  { status: \"cleaning\", beds: 18, fill: \"var(--color-cleaning)\" },\n  { status: \"available\", beds: 46, fill: \"var(--color-available)\" },\n]\n\nconst chartConfig = {\n  beds: {\n    label: \"Beds\",\n  },\n  occupied: {\n    label: \"Occupied\",\n    color: \"var(--chart-2)\",\n  },\n  cleaning: {\n    label: \"Cleaning\",\n    color: \"var(--chart-4)\",\n  },\n  available: {\n    label: \"Available\",\n    color: \"var(--chart-1)\",\n  },\n} satisfies ChartConfig\n\nexport function ChartPieOccupancy() {\n  const total = chartData.reduce((sum, { beds }) => sum + beds, 0)\n  const occupiedBeds = chartData.find(({ status }) => status === \"occupied\")!\n  const occupied = Math.round((occupiedBeds.beds / total) * 100)\n  return (\n    <Card className=\"flex flex-col\">\n      <CardHeader className=\"items-center pb-0\">\n        <CardTitle>Bed occupancy</CardTitle>\n        <CardDescription>All wards, now</CardDescription>\n      </CardHeader>\n      <CardContent className=\"flex-1 pb-0\">\n        <ChartContainer\n          config={chartConfig}\n          className=\"mx-auto aspect-square max-h-[250px]\"\n        >\n          <PieChart>\n            <ChartTooltip\n              cursor={false}\n              content={<ChartTooltipContent hideLabel />}\n            />\n            <Pie\n              data={chartData}\n              dataKey=\"beds\"\n              nameKey=\"status\"\n              innerRadius={60}\n              strokeWidth={5}\n            >\n              <Label\n                content={({ viewBox }) => {\n                  if (viewBox && \"cx\" in viewBox && \"cy\" in viewBox) {\n                    return (\n                      <text\n                        x={viewBox.cx}\n                        y={viewBox.cy}\n                        textAnchor=\"middle\"\n                        dominantBaseline=\"middle\"\n                      >\n                        <tspan\n                          x={viewBox.cx}\n                          y={viewBox.cy}\n                          className=\"fill-foreground text-3xl font-bold\"\n                        >\n                          {occupied}%\n                        </tspan>\n                        <tspan\n                          x={viewBox.cx}\n                          y={(viewBox.cy || 0) + 24}\n                          className=\"fill-muted-foreground\"\n                        >\n                          occupied\n                        </tspan>\n                      </text>\n                    )\n                  }\n                }}\n              />\n            </Pie>\n            <ChartLegend content={<ChartLegendContent nameKey=\"status\" />} />\n          </PieChart>\n        </ChartContainer>\n      </CardContent>\n      <CardFooter className=\"flex-col gap-2 text-sm\">\n        <div className=\"flex items-center gap-2 leading-none font-medium\">\n          {chartData.find(({ status }) => status === \"available\")!.beds} beds\n          available now\n        </div>\n        <div className=\"leading-none text-muted-foreground\">\n          {total} beds across all wards; illustrative data\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "docs": "Bed occupancy pie chart: https://organui.com/charts/pie#chart-pie-occupancy",
  "categories": [
    "charts",
    "charts-pie"
  ],
  "type": "registry:block"
}