{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-bar-appointments",
  "title": "Missed appointments bar chart",
  "description": "Outpatient did-not-attend rate by month, against a target.",
  "dependencies": [
    "recharts@^3.8.0"
  ],
  "registryDependencies": [
    "card",
    "badge",
    "chart"
  ],
  "files": [
    {
      "path": "registry/base-nova/charts/chart-bar-appointments.tsx",
      "content": "\"use client\"\n\nimport {\n  Bar,\n  BarChart,\n  CartesianGrid,\n  Cell,\n  Label,\n  ReferenceLine,\n  XAxis,\n  YAxis,\n} from \"recharts\"\n\nimport {\n  Card,\n  CardAction,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n  CardTitle,\n} from \"@/components/ui/card\"\nimport { Badge } from \"@/components/ui/badge\"\nimport {\n  ChartContainer,\n  ChartTooltip,\n  type ChartConfig,\n} from \"@/components/ui/chart\"\nimport { IconPlaceholder } from \"@/icons/icon-placeholder\"\n\nexport const description =\n  \"Outpatient did-not-attend rate by month, against a target\"\n\n// Outpatient appointments attended and missed each month, illustrative.\nconst chartData = [\n  { month: \"January\", attended: 486, missed: 64 },\n  { month: \"February\", attended: 505, missed: 58 },\n  { month: \"March\", attended: 537, missed: 71 },\n  { month: \"April\", attended: 473, missed: 49 },\n  { month: \"May\", attended: 509, missed: 52 },\n  { month: \"June\", attended: 514, missed: 47 },\n].map((month) => ({\n  ...month,\n  rate:\n    Math.round((month.missed / (month.attended + month.missed)) * 1000) / 10,\n}))\n\nconst chartConfig = {\n  rate: {\n    label: \"Did not attend\",\n    color: \"var(--chart-2)\",\n  },\n} satisfies ChartConfig\n\n// A local target for the share of appointments missed; set your own.\nconst target = 10\nconst latest = chartData.at(-1)!\nconst first = chartData[0]!\nconst atTarget = latest.rate <= target\n\nexport function ChartBarAppointments() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Missed appointments</CardTitle>\n        <CardDescription>Outpatient did-not-attend rate</CardDescription>\n        <CardAction className=\"flex flex-col items-end gap-1.5\">\n          <div className=\"text-2xl leading-none font-semibold\">\n            {latest.rate}%{\" \"}\n            <span className=\"text-sm font-normal text-muted-foreground\">\n              in {latest.month.slice(0, 3)}\n            </span>\n          </div>\n          <Badge variant=\"outline\">\n            {atTarget ? (\n              <IconPlaceholder\n                lucide=\"CheckIcon\"\n                tabler=\"IconCheck\"\n                hugeicons=\"Tick02Icon\"\n                phosphor=\"CheckIcon\"\n                remixicon=\"RiCheckLine\"\n                data-icon=\"inline-start\"\n              />\n            ) : (\n              <IconPlaceholder\n                lucide=\"TriangleAlertIcon\"\n                tabler=\"IconAlertTriangle\"\n                hugeicons=\"Alert02Icon\"\n                phosphor=\"WarningIcon\"\n                remixicon=\"RiAlertLine\"\n                data-icon=\"inline-start\"\n              />\n            )}\n            {atTarget ? \"At target\" : \"Above target\"}\n          </Badge>\n        </CardAction>\n      </CardHeader>\n      <CardContent>\n        <ChartContainer config={chartConfig}>\n          <BarChart\n            accessibilityLayer\n            data={chartData}\n            margin={{ left: -12, right: 12, top: 12 }}\n          >\n            <CartesianGrid vertical={false} />\n            <XAxis\n              dataKey=\"month\"\n              tickLine={false}\n              tickMargin={10}\n              axisLine={false}\n              tickFormatter={(value) => value.slice(0, 3)}\n            />\n            <YAxis\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              domain={[0, 14]}\n              ticks={[0, 5, 10]}\n              tickFormatter={(value) => `${value}%`}\n            />\n            <ChartTooltip\n              cursor={false}\n              content={({ active, payload }) => {\n                const row = payload?.[0]?.payload as\n                  (typeof chartData)[number] | undefined\n                if (!active || !row) return null\n                return (\n                  <div className=\"grid min-w-[10rem] gap-1 rounded-lg border bg-background px-2.5 py-1.5 text-xs shadow-xl\">\n                    <div className=\"font-medium\">{row.month}</div>\n                    <div className=\"flex items-baseline justify-between gap-4\">\n                      <span className=\"text-muted-foreground\">\n                        Did not attend\n                      </span>\n                      <span className=\"font-mono font-medium tabular-nums\">\n                        {row.rate}%\n                      </span>\n                    </div>\n                    <div className=\"flex items-baseline justify-between gap-4\">\n                      <span className=\"text-muted-foreground\">Missed</span>\n                      <span className=\"font-mono tabular-nums\">\n                        {row.missed} of {row.attended + row.missed}\n                      </span>\n                    </div>\n                  </div>\n                )\n              }}\n            />\n            {/* Months over target at full strength, the rest muted. */}\n            <Bar dataKey=\"rate\" radius={4} maxBarSize={32}>\n              {chartData.map((month) => (\n                <Cell\n                  key={month.month}\n                  fill=\"var(--color-rate)\"\n                  fillOpacity={month.rate > target ? 1 : 0.35}\n                />\n              ))}\n            </Bar>\n            <ReferenceLine\n              y={target}\n              stroke=\"var(--muted-foreground)\"\n              strokeDasharray=\"4 4\"\n            >\n              <Label\n                value={`Target ${target}%`}\n                position=\"insideTopRight\"\n                className=\"fill-muted-foreground\"\n                fontSize={11}\n              />\n            </ReferenceLine>\n          </BarChart>\n        </ChartContainer>\n      </CardContent>\n      <CardFooter className=\"flex-col items-start gap-2 text-sm\">\n        <div className=\"flex items-center gap-2 leading-none font-medium\">\n          {latest.rate <= first.rate ? \"Down\" : \"Up\"} from {first.rate}% in{\" \"}\n          {first.month}{\" \"}\n          {latest.rate <= first.rate ? (\n            <IconPlaceholder\n              lucide=\"TrendingDownIcon\"\n              tabler=\"IconTrendingDown\"\n              hugeicons=\"ChartDownIcon\"\n              phosphor=\"TrendDownIcon\"\n              remixicon=\"RiArrowDownLine\"\n              className=\"size-4\"\n            />\n          ) : (\n            <IconPlaceholder\n              lucide=\"TrendingUpIcon\"\n              tabler=\"IconTrendingUp\"\n              hugeicons=\"ChartUpIcon\"\n              phosphor=\"TrendUpIcon\"\n              remixicon=\"RiArrowUpLine\"\n              className=\"size-4\"\n            />\n          )}\n        </div>\n        <div className=\"leading-none text-muted-foreground\">\n          Muted bars meet the target; illustrative data\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "docs": "Missed appointments bar chart: https://organui.com/charts/bar#chart-bar-appointments",
  "categories": [
    "charts",
    "charts-bar"
  ],
  "type": "registry:block"
}