{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-bar-blood-pressure",
  "title": "Ambulatory blood pressure bar chart",
  "description": "24-hour blood pressure as range bars from diastolic to systolic, with the overnight dip.",
  "dependencies": [
    "recharts@^3.8.0"
  ],
  "registryDependencies": [
    "card",
    "badge",
    "chart"
  ],
  "files": [
    {
      "path": "registry/base-nova/charts/chart-bar-blood-pressure.tsx",
      "content": "\"use client\"\n\nimport {\n  Bar,\n  BarChart,\n  CartesianGrid,\n  Label,\n  ReferenceArea,\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 =\n  \"24-hour blood pressure, as range bars from diastolic to systolic\"\n\n// Readings every two hours from an ambulatory monitor, for a fictional\n// patient. Each bar spans diastolic to systolic, as on a paper vitals chart.\nconst chartData = [\n  { time: \"08:00\", systolic: 136, diastolic: 86, asleep: false },\n  { time: \"10:00\", systolic: 140, diastolic: 88, asleep: false },\n  { time: \"12:00\", systolic: 142, diastolic: 90, asleep: false },\n  { time: \"14:00\", systolic: 138, diastolic: 86, asleep: false },\n  { time: \"16:00\", systolic: 141, diastolic: 89, asleep: false },\n  { time: \"18:00\", systolic: 137, diastolic: 85, asleep: false },\n  { time: \"20:00\", systolic: 132, diastolic: 82, asleep: false },\n  { time: \"22:00\", systolic: 124, diastolic: 76, asleep: false },\n  { time: \"00:00\", systolic: 116, diastolic: 70, asleep: true },\n  { time: \"02:00\", systolic: 112, diastolic: 68, asleep: true },\n  { time: \"04:00\", systolic: 114, diastolic: 69, asleep: true },\n  { time: \"06:00\", systolic: 128, diastolic: 78, asleep: false },\n].map((reading) => ({\n  ...reading,\n  pressure: [reading.diastolic, reading.systolic],\n}))\n\nconst chartConfig = {\n  pressure: {\n    label: \"Blood pressure\",\n    color: \"var(--chart-2)\",\n  },\n} satisfies ChartConfig\n\nfunction meanSystolic(readings: typeof chartData) {\n  return (\n    readings.reduce((sum, { systolic }) => sum + systolic, 0) / readings.length\n  )\n}\n\n// How far systolic pressure falls asleep. A fall of 10% or more is the usual\n// pattern; less, a \"non-dipper\", is a cardiovascular risk marker.\nconst awake = meanSystolic(chartData.filter(({ asleep }) => !asleep))\nconst asleep = meanSystolic(chartData.filter(({ asleep }) => asleep))\nconst dip = Math.round(((awake - asleep) / awake) * 100)\nconst dipper = dip >= 10\nconst night = chartData.filter(({ asleep }) => asleep)\n\nexport function ChartBarBloodPressure() {\n  return (\n    <Card>\n      <CardHeader>\n        <CardTitle>Ambulatory blood pressure</CardTitle>\n        <CardDescription>\n          Every two hours over 24 hours, in mmHg\n        </CardDescription>\n        <CardAction className=\"flex flex-col items-end gap-1.5\">\n          <div className=\"text-2xl leading-none font-semibold\">\n            {dip}%{\" \"}\n            <span className=\"text-sm font-normal text-muted-foreground\">\n              dip\n            </span>\n          </div>\n          <Badge variant=\"outline\">\n            {dipper ? (\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            {dipper ? \"Dipper\" : \"Non-dipper\"}\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 }}\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={[60, 150]}\n            />\n            {/* The hours asleep, when pressure should fall. */}\n            <ReferenceArea\n              x1={night[0]!.time}\n              x2={night.at(-1)!.time}\n              fill=\"var(--muted-foreground)\"\n              fillOpacity={0.08}\n            >\n              <Label\n                value=\"Asleep\"\n                position=\"insideTop\"\n                className=\"fill-muted-foreground\"\n                fontSize={11}\n              />\n            </ReferenceArea>\n            <ChartTooltip\n              cursor={false}\n              content={\n                <ChartTooltipContent\n                  formatter={(value) =>\n                    Array.isArray(value)\n                      ? `${value[1]}/${value[0]} mmHg`\n                      : String(value)\n                  }\n                />\n              }\n            />\n            <Bar\n              dataKey=\"pressure\"\n              fill=\"var(--color-pressure)\"\n              radius={4}\n              maxBarSize={14}\n            />\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          Systolic averages {Math.round(awake)} awake, {Math.round(asleep)}{\" \"}\n          asleep\n        </div>\n        <div className=\"leading-none text-muted-foreground\">\n          Each bar runs diastolic to systolic; a fictional patient\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "docs": "Ambulatory blood pressure bar chart: https://organui.com/charts/bar#chart-bar-blood-pressure",
  "categories": [
    "charts",
    "charts-bar"
  ],
  "type": "registry:block"
}