{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "line-chart-kpi-01",
  "description": "This week as a filled area over last week as a dashed line, with the days it fell behind.",
  "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/line-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 { TinyAreaChart } 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'\nimport { formatList } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface DailyComparison {\n  label: string\n  previous: number\n  value: number\n}\n\ninterface LineChartKPI1Props extends BlockStateProps {\n  comparison: string\n  /** @default 'This week' */\n  currentLabel?: string\n  /** Leave out, or pass no days, to show the empty state. */\n  data?: DailyComparison[]\n  format?: KPIFormat\n  /** @default 112 */\n  height?: number\n  title: string\n}\n\nconst exampleProps: LineChartKPI1Props = {\n  comparison: 'last week',\n  data: [\n    { label: 'Mon', previous: 6_100, value: 6_420 },\n    { label: 'Tue', previous: 6_650, value: 7_180 },\n    { label: 'Wed', previous: 6_020, value: 5_890 },\n    { label: 'Thu', previous: 6_900, value: 7_560 },\n    { label: 'Fri', previous: 7_240, value: 8_030 },\n    { label: 'Sat', previous: 5_310, value: 5_720 },\n    { label: 'Sun', previous: 4_880, value: 5_430 },\n  ],\n  format: 'compact',\n  title: 'Visitors',\n}\n\nfunction describeLead(data: DailyComparison[]): [string, string] {\n  const behind = data.filter((point) => point.value < point.previous)\n  const ahead = data.length - behind.length\n  if (behind.length === 0) return ['ahead of', 'every day.']\n  if (ahead === 0) return ['behind', 'every day.']\n  return [\n    'ahead of',\n    `on ${ahead} of ${data.length} days, behind on ${formatList(behind.map((point) => point.label))}.`,\n  ]\n}\n\nconst LineChartKPI1 = (props: LineChartKPI1Props) => {\n  const {\n    comparison,\n    currentLabel = 'This week',\n    data = [],\n    format,\n    height = 112,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const total = data.reduce((sum, point) => sum + point.value, 0)\n  const previous = data.reduce((sum, point) => sum + point.previous, 0)\n  const [lead, rest] = describeLead(data)\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                <TinyAreaChart\n                  accessibilityLayer={false}\n                  areas={[\n                    {\n                      dataKey: 'previous',\n                      fill: 'none',\n                      name: comparison.charAt(0).toUpperCase() + comparison.slice(1),\n                      stroke: 'var(--color-muted-foreground)',\n                      strokeDasharray: '3 3',\n                      strokeWidth: 1.5,\n                    },\n                    {\n                      dataKey: 'value',\n                      fill: 'var(--color-chart-2)',\n                      fillOpacity: 0.3,\n                      name: currentLabel,\n                      stroke: 'var(--color-chart-2)',\n                    },\n                  ]}\n                  data={data}\n                  formatter={getKPIFormatter(format)}\n                  height={height}\n                  markLast='value'\n                  scale='data'\n                  xAxisKey='label'\n                />\n              </KPIChart>\n              <BlockReady className='text-xs'>\n                <p className='text-muted-foreground text-xs'>\n                  <span\n                    aria-hidden\n                    className='bg-chart-2 mr-1.5 inline-block h-0.5 w-3 align-middle'\n                  />\n                  {currentLabel} was {lead}\n                  <span\n                    aria-hidden\n                    className='border-muted-foreground mx-1.5 inline-block w-3 border-t-[1.5px] border-dashed align-middle'\n                  />\n                  {comparison} {rest}\n                </p>\n              </BlockReady>\n            </KPIContent>\n          </KPI>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  LineChartKPI1,\n  exampleProps as lineChartKpi1ExampleProps,\n  type DailyComparison,\n  type LineChartKPI1Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kpi/line-chart-kpi-01.tsx"
    }
  ],
  "meta": {
    "shows": "This week as a filled area over last week as a dashed line, with the days it fell behind.",
    "size": "compact",
    "usedWith": [
      "bar-chart-kpi-01",
      "comparison-01",
      "chart-panel-02"
    ],
    "component": "LineChartKPI1",
    "props": "{ comparison: string; currentLabel?: string; data?: { label: string; previous: number; value: number }[]; format?: \"number\" | \"compact\" | \"currency\" | \"currency-compact\" | \"percent\"; height?: number; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
