{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboard-chart",
  "title": "Dashboard chart",
  "description": "Plain bars of a widget's counts, hidden from assistive technology, above the table that holds the same counts as their text equivalent. No chart library.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/dashboard-table",
    "@registrystack/dashboard-cells",
    "@registrystack/dashboard-content",
    "@registrystack/lib-content"
  ],
  "files": [
    {
      "path": "dashboard/dashboard-chart.tsx",
      "content": "import type {\n  DashboardWidgetResult,\n  DashboardWidgetView,\n} from \"@registrystack/app-runtime\";\nimport { DashboardTable } from \"@/blocks/dashboard/dashboard-table\";\nimport {\n  disclosedValue,\n  minimumCountOf,\n} from \"@/blocks/dashboard/dashboard-values\";\nimport { useDashboardContent } from \"@/blocks/dashboard/dashboard-content\";\nimport { useLocale } from \"@/blocks/lib/content\";\n\n/**\n * Bars of the counts of a ready result, scaled to the largest count shown,\n * above the table that holds the same counts in words. The bars are\n * decoration for sighted readers and are hidden from assistive technology;\n * a withheld count has no bar. The bar lengths use the values BReg\n * disclosed, so a rounded count draws its rounded length.\n */\nexport function DashboardChart({\n  widget,\n  result,\n}: {\n  widget: DashboardWidgetView;\n  result: DashboardWidgetResult;\n}) {\n  const c = useDashboardContent(),\n    locale = useLocale();\n  const rows = result.rows ?? [];\n  const largest = Math.max(1, ...rows.map((row) => row.value ?? 0));\n  const minimum = minimumCountOf(result.context);\n  return (\n    <>\n      <div className=\"dashboard-bars\" aria-hidden=\"true\">\n        {rows.map((row) => (\n          <div className=\"dashboard-bar-row\" key={row.code}>\n            <span>{row.label ?? row.code}</span>\n            <span className=\"dashboard-bar-track\">\n              {row.value !== null && (\n                <span\n                  className=\"dashboard-bar\"\n                  style={{ width: `${(row.value / largest) * 100}%` }}\n                />\n              )}\n            </span>\n            <strong>{disclosedValue(c, locale, row, minimum)}</strong>\n          </div>\n        ))}\n      </div>\n      <DashboardTable widget={widget} result={result} />\n    </>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/dashboard/dashboard-chart.tsx"
    }
  ],
  "type": "registry:block"
}