{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-area-heart-rate",
  "title": "Heart rate area chart",
  "description": "Heart rate across a shift, as a gradient area chart.",
  "dependencies": [
    "recharts@^3.8.0"
  ],
  "registryDependencies": [
    "card",
    "badge",
    "chart"
  ],
  "files": [
    {
      "path": "registry/base-nova/charts/chart-area-heart-rate.tsx",
      "content": "\"use client\"\n\nimport {\n  Area,\n  AreaChart,\n  CartesianGrid,\n  Label,\n  ReferenceArea,\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  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\"\nimport { IconPlaceholder } from \"@/icons/icon-placeholder\"\n\nexport const description = \"Heart rate across a shift, as a gradient area chart\"\n\n// Hourly readings for one fictional patient.\nconst chartData = [\n  { time: \"07:00\", heartRate: 72 },\n  { time: \"08:00\", heartRate: 76 },\n  { time: \"09:00\", heartRate: 84 },\n  { time: \"10:00\", heartRate: 91 },\n  { time: \"11:00\", heartRate: 88 },\n  { time: \"12:00\", heartRate: 79 },\n  { time: \"13:00\", heartRate: 74 },\n  { time: \"14:00\", heartRate: 70 },\n  { time: \"15:00\", heartRate: 73 },\n  { time: \"16:00\", heartRate: 77 },\n  { time: \"17:00\", heartRate: 82 },\n  { time: \"18:00\", heartRate: 75 },\n]\n\nconst chartConfig = {\n  heartRate: {\n    label: \"Heart rate (bpm)\",\n    color: \"var(--chart-3)\",\n  },\n} satisfies ChartConfig\n\n// What happened during the shift, marked on the timeline so a change in the\n// readings can be read against its cause.\nconst events = [\n  { time: \"08:00\", label: \"Fever\" },\n  { time: \"11:00\", label: \"Paracetamol\" },\n]\n\nconst latest = chartData.at(-1)!\n// The usual adult resting range, drawn behind the readings.\nconst normal = { low: 60, high: 100 }\nconst inRange =\n  latest.heartRate >= normal.low && latest.heartRate <= normal.high\n\nconst peak = chartData.reduce((a, b) => (b.heartRate > a.heartRate ? b : a))\n\nexport function ChartAreaHeartRate() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Heart rate</CardTitle>\n        <CardDescription>Hourly, across a day shift</CardDescription>\n        <CardAction className=\"flex flex-col items-end gap-1.5\">\n          <div className=\"text-2xl leading-none font-semibold\">\n            {latest.heartRate}{\" \"}\n            <span className=\"text-sm font-normal text-muted-foreground\">\n              bpm\n            </span>\n          </div>\n          <Badge variant=\"outline\">\n            {inRange ? (\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            {inRange ? \"In range\" : \"Out of range\"}\n          </Badge>\n        </CardAction>\n      </CardHeader>\n      <CardContent>\n        <ChartContainer config={chartConfig}>\n          <AreaChart\n            accessibilityLayer\n            data={chartData}\n            margin={{ left: -12, right: 12 }}\n          >\n            <CartesianGrid vertical={false} />\n            <XAxis\n              dataKey=\"time\"\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              interval={2}\n            />\n            <YAxis\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              domain={[50, 110]}\n            />\n            <ReferenceArea\n              y1={normal.low}\n              y2={normal.high}\n              fill=\"var(--muted-foreground)\"\n              fillOpacity={0.08}\n            >\n              <Label\n                value={`Normal ${normal.low}–${normal.high}`}\n                position=\"insideBottomLeft\"\n                className=\"fill-muted-foreground\"\n                fontSize={11}\n              />\n            </ReferenceArea>\n            {events.map((event) => (\n              <ReferenceLine\n                key={event.time}\n                x={event.time}\n                stroke=\"var(--muted-foreground)\"\n              >\n                <Label\n                  value={event.label}\n                  position=\"insideTopLeft\"\n                  className=\"fill-foreground\"\n                  fontSize={11}\n                />\n              </ReferenceLine>\n            ))}\n            <ChartTooltip cursor={false} content={<ChartTooltipContent />} />\n            <defs>\n              <linearGradient id=\"fillHeartRate\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop\n                  offset=\"5%\"\n                  stopColor=\"var(--color-heartRate)\"\n                  stopOpacity={0.8}\n                />\n                <stop\n                  offset=\"95%\"\n                  stopColor=\"var(--color-heartRate)\"\n                  stopOpacity={0.1}\n                />\n              </linearGradient>\n            </defs>\n            <Area\n              dataKey=\"heartRate\"\n              type=\"monotone\"\n              fill=\"url(#fillHeartRate)\"\n              stroke=\"var(--color-heartRate)\"\n            />\n          </AreaChart>\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          Peaks at {peak.heartRate} bpm at {peak.time}\n        </div>\n        <div className=\"leading-none text-muted-foreground\">\n          {chartData[0]!.time} to {latest.time}; a fictional patient\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "docs": "Heart rate area chart: https://organui.com/charts/area#chart-area-heart-rate",
  "categories": [
    "charts",
    "charts-area"
  ],
  "type": "registry:block"
}