{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bar-chart-kpi-01",
  "description": "The week's total with a bar for each day and the change on the week before.",
  "dependencies": [
    "recharts"
  ],
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/chart.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kpi/bar-chart-kpi-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { TinyBarChart } from '@/registry/components/dashboardblocks/chart'\nimport {\n  KPI,\n  KPIChange,\n  KPIChart,\n  KPIContent,\n  KPITitle,\n  type KPIFormat,\n  KPIValue,\n  describeSeries,\n  getKPIFormatter,\n} from '@/registry/components/dashboardblocks/kpi'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface DailyValue {\n  label: string\n  value: number\n}\n\ninterface BarChartKPI1Props extends BlockStateProps {\n  comparison: string\n  /** Leave out, or pass no days, to show the empty state. */\n  data?: DailyValue[]\n  format?: KPIFormat\n  /** @default 144 */\n  height?: number\n  previous?: number\n  title: string\n}\n\nconst exampleProps: BarChartKPI1Props = {\n  comparison: 'last week',\n  data: [\n    { label: 'Mon', value: 3_200 },\n    { label: 'Tue', value: 4_500 },\n    { label: 'Wed', value: 2_800 },\n    { label: 'Thu', value: 5_200 },\n    { label: 'Fri', value: 6_100 },\n    { label: 'Sat', value: 4_800 },\n    { label: 'Sun', value: 5_700 },\n  ],\n  format: 'currency',\n  previous: 30_050,\n  title: 'Revenue this week',\n}\n\nconst compactFormat = (format: KPIFormat = 'number'): KPIFormat =>\n  format === 'currency' ? 'currency-compact' : format === 'number' ? 'compact' : format\n\nconst BarChartKPI1 = (props: BarChartKPI1Props) => {\n  const {\n    comparison,\n    data = [],\n    format,\n    height = 144,\n    previous,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const total = data.reduce((sum, point) => sum + point.value, 0)\n  const formatter = getKPIFormatter(format)\n  const best = data.reduce(\n    (top, point, index) => (point.value > data[top].value ? index : top),\n    0,\n  )\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={getBlockState(status, data)}>\n      <Card>\n        <CardContent>\n          <KPI>\n            <KPIContent className='gap-3'>\n              <div className='flex flex-col gap-1'>\n                <KPITitle>{title}</KPITitle>\n                <KPIValue value={total} format={format} animated />\n                <KPIChange comparison={comparison} previous={previous} value={total} />\n              </div>\n              <KPIChart label={describeSeries(`${title} by day`, data, format)}>\n                <TinyBarChart\n                  accessibilityLayer={false}\n                  bars={[{ dataKey: 'value', fill: 'var(--color-chart-2)' }]}\n                  data={data}\n                  formatter={getKPIFormatter(compactFormat(format))}\n                  height={height}\n                  highlightIndex={best}\n                  reference={{\n                    label: `avg ${formatter(Math.round(total / data.length))}`,\n                    value: total / data.length,\n                  }}\n                  xAxisKey='label'\n                />\n              </KPIChart>\n              <BlockReady className='text-xs'>\n                <p className='text-muted-foreground text-xs'>\n                  {data[best]?.label} was the best day, at{' '}\n                  {formatter(data[best]?.value ?? 0)}.\n                </p>\n              </BlockReady>\n            </KPIContent>\n          </KPI>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  BarChartKPI1,\n  exampleProps as barChartKpi1ExampleProps,\n  type BarChartKPI1Props,\n  type DailyValue,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kpi/bar-chart-kpi-01.tsx"
    }
  ],
  "meta": {
    "shows": "The week's total with a bar for each day and the change on the week before.",
    "size": "compact",
    "usedWith": [
      "kpi-01",
      "line-chart-kpi-01",
      "chart-panel-01"
    ],
    "component": "BarChartKPI1",
    "props": "{ comparison: string; data?: { label: string; value: number }[]; format?: \"number\" | \"compact\" | \"currency\" | \"currency-compact\" | \"percent\"; height?: number; previous?: number; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
