{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-area-admissions",
  "title": "Admissions area chart",
  "description": "Monthly admissions against the range of the past three years, as surveillance reports draw them.",
  "dependencies": [
    "recharts@^3.8.0"
  ],
  "registryDependencies": [
    "card",
    "badge",
    "chart"
  ],
  "files": [
    {
      "path": "registry/base-nova/charts/chart-area-admissions.tsx",
      "content": "\"use client\"\n\nimport {\n  Area,\n  CartesianGrid,\n  ComposedChart,\n  Line,\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  ChartLegend,\n  ChartLegendContent,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\"\nimport { IconPlaceholder } from \"@/icons/icon-placeholder\"\n\nexport const description =\n  \"Monthly admissions against the range of the past three years\"\n\n// Admissions this year so far, against the lowest and highest of the same\n// month over the past three years, as surveillance reports draw them.\n// Illustrative figures for one hospital.\nconst chartData = [\n  { month: \"Jan\", thisYear: 1186, low: 1090, high: 1240 },\n  { month: \"Feb\", thisYear: 1305, low: 1060, high: 1210 },\n  { month: \"Mar\", thisYear: 1237, low: 1040, high: 1190 },\n  { month: \"Apr\", thisYear: 1073, low: 980, high: 1120 },\n  { month: \"May\", thisYear: 1009, low: 960, high: 1100 },\n  { month: \"Jun\", thisYear: 1114, low: 950, high: 1080 },\n  { month: \"Jul\", thisYear: null, low: 940, high: 1070 },\n  { month: \"Aug\", thisYear: null, low: 930, high: 1060 },\n  { month: \"Sep\", thisYear: null, low: 970, high: 1110 },\n  { month: \"Oct\", thisYear: null, low: 1010, high: 1150 },\n  { month: \"Nov\", thisYear: null, low: 1050, high: 1190 },\n  { month: \"Dec\", thisYear: null, low: 1100, high: 1260 },\n].map((month) => ({ ...month, usual: [month.low, month.high] }))\n\nconst chartConfig = {\n  thisYear: {\n    label: \"This year\",\n    color: \"var(--chart-2)\",\n  },\n  usual: {\n    label: \"Past 3 years\",\n    color: \"var(--muted-foreground)\",\n  },\n} satisfies ChartConfig\n\nconst reported = chartData.filter(\n  (month): month is (typeof chartData)[number] & { thisYear: number } =>\n    month.thisYear !== null\n)\nconst latest = reported.at(-1)!\nconst aboveRange = latest.thisYear > latest.high\nconst monthsAbove = reported.filter(({ thisYear, high }) => thisYear > high)\n\nexport function ChartAreaAdmissions() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Admissions</CardTitle>\n        <CardDescription>Monthly, against the past 3 years</CardDescription>\n        <CardAction className=\"flex flex-col items-end gap-1.5\">\n          <div className=\"text-2xl leading-none font-semibold\">\n            {latest.thisYear.toLocaleString(\"en-US\")}{\" \"}\n            <span className=\"text-sm font-normal text-muted-foreground\">\n              in {latest.month}\n            </span>\n          </div>\n          <Badge variant=\"outline\">\n            {aboveRange ? (\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              <IconPlaceholder\n                lucide=\"CheckIcon\"\n                tabler=\"IconCheck\"\n                hugeicons=\"Tick02Icon\"\n                phosphor=\"CheckIcon\"\n                remixicon=\"RiCheckLine\"\n                data-icon=\"inline-start\"\n              />\n            )}\n            {aboveRange ? \"Above usual\" : \"Within usual\"}\n          </Badge>\n        </CardAction>\n      </CardHeader>\n      <CardContent>\n        <ChartContainer config={chartConfig}>\n          <ComposedChart\n            accessibilityLayer\n            data={chartData}\n            margin={{ left: -12, right: 12 }}\n          >\n            <CartesianGrid vertical={false} />\n            <XAxis\n              dataKey=\"month\"\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              interval={1}\n            />\n            <YAxis\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              domain={[800, 1400]}\n              ticks={[900, 1100, 1300]}\n            />\n            <ChartTooltip\n              cursor={false}\n              content={\n                <ChartTooltipContent\n                  indicator=\"line\"\n                  formatter={(value, name) => (\n                    <div className=\"flex min-w-[140px] items-center text-xs text-muted-foreground\">\n                      {chartConfig[name as keyof typeof chartConfig]?.label}\n                      <span className=\"ml-auto font-mono font-medium text-foreground tabular-nums\">\n                        {Array.isArray(value)\n                          ? value\n                              .map((n) => n.toLocaleString(\"en-US\"))\n                              .join(\"–\")\n                          : Number(value).toLocaleString(\"en-US\")}\n                      </span>\n                    </div>\n                  )}\n                />\n              }\n            />\n            {/* The usual range, from the past three years' lowest to highest. */}\n            <Area\n              dataKey=\"usual\"\n              type=\"monotone\"\n              fill=\"var(--color-usual)\"\n              fillOpacity={0.15}\n              stroke=\"none\"\n              activeDot={false}\n            />\n            <Line\n              dataKey=\"thisYear\"\n              type=\"monotone\"\n              stroke=\"var(--color-thisYear)\"\n              strokeWidth={2}\n              dot={{ r: 3, fill: \"var(--color-thisYear)\" }}\n              connectNulls={false}\n            />\n            <ChartLegend content={<ChartLegendContent />} />\n          </ComposedChart>\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          {monthsAbove.length\n            ? `Above the usual range in ${monthsAbove.length} of ${reported.length} months`\n            : \"Within the usual range all year\"}\n        </div>\n        <div className=\"leading-none text-muted-foreground\">\n          Shaded: the past three years&apos; lowest to highest; illustrative\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "docs": "Admissions area chart: https://organui.com/charts/area#chart-area-admissions",
  "categories": [
    "charts",
    "charts-area"
  ],
  "type": "registry:block"
}