{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "battery-cells",
  "type": "registry:component",
  "title": "Battery cells",
  "description": "Charge per unit, like a row of batteries. Sample data: charge across eight vans, Van 22 at 18%, two vans charging.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-batteries"
  ],
  "files": [
    {
      "path": "registry/chartory/components/battery-cells.tsx",
      "type": "registry:component",
      "target": "components/chartory/battery-cells.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Battery cells (Chartory chart 078): sizes xs | s | m | l, laid out again from the data at each\n// size; collection \"hearth\" (default) or \"signal\" (with @chartory/signal, Code and Complete). Data in the type's shape (default: the sample). Docs:\n// https://usechartory.com/docs/charts/battery-cells\nimport { ChartView, type ChartViewProps } from \"@/lib/chartory/charts/chart-view\"\nimport { registerChart } from \"@/lib/chartory/charts/defs\"\nimport { data as sample } from \"@/lib/chartory/charts/types/078-battery-cells/data\"\nimport { def } from \"@/lib/chartory/charts/types/078-battery-cells/layout\"\n\nregisterChart(def, sample)\n\nexport type BatteryCellsData = typeof sample\nexport type BatteryCellsProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: BatteryCellsData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: BatteryCellsData[]\n}\n\nexport function BatteryCells(props: BatteryCellsProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/078-battery-cells/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/078-battery-cells/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 078 Battery cells · sample data (Figma chart/078, logistics: charge and range of 8 delivery vans).\nimport type { BatteriesData } from \"../../plots/batteries\";\n\nexport const data: BatteriesData = {\n  items: [\n    { label: \"Van 21\", v: 92, sub: \"210 KM\" }, { label: \"Van 22\", v: 18, sub: \"38 KM\" }, { label: \"Van 23\", v: 79, sub: \"180 KM\" },\n    { label: \"Van 24\", v: 71, sub: \"162 KM\", charging: true }, { label: \"Van 25\", v: 95, sub: \"220 KM\" }, { label: \"Van 26\", v: 23, sub: \"50 KM\", charging: true },\n    { label: \"Van 27\", v: 96, sub: \"224 KM\" }, { label: \"Van 28\", v: 94, sub: \"216 KM\" },\n  ],\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/078-battery-cells/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/078-battery-cells/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 078 Battery cells (Figma chart/078): C.batteries on the van fleet; no legend (each cell is labelled).\nimport type { ChartDef, TooltipSpec } from \"../../core/shell\";\nimport { batteries } from \"../../plots/batteries\";\nimport { data } from \"./data\";\n\nconst low = data.items.filter((q) => q.v < 25);\nconst km = (s: string) => s.replace(\" KM\", \" km\");\n\nconst wob = (i: number, step: number) => Math.sin(i * 2.1 + step * 1.7 + 0.4);\n/** A later reading: each van's charge moves inside its status band, the range follows the van's own km per %. */\nfunction update(d0: unknown, step: number): typeof data {\n  const d = d0 as typeof data;\n  return {\n    items: d.items.map((q, i) => {\n      const [lo, hi] = q.v < 25 ? [5, 24] : q.v < 50 ? [25, 49] : [50, 98];\n      const v = Math.min(hi, Math.max(lo, Math.round(q.v * (1 + 0.16 * wob(i, step)))));\n      const kmPer = parseInt(q.sub, 10) / q.v;\n      return { ...q, v, sub: Math.round(kmPer * v) + \" KM\" };\n    }),\n  };\n}\n\n/** Hover: one van (its charge bar and caps line): charge, range, charging. */\nfunction tip(d0: unknown, g: number): TooltipSpec | null {\n  const q = (d0 as typeof data).items[g];\n  return q ? { kind: \"value\", text: `${q.label} · ${q.v}% · ${km(q.sub)}${q.charging ? \" · charging\" : \"\"}` } : null;\n}\n\nexport const def: ChartDef = {\n  no: 78,\n  slug: \"battery-cells\",\n  legend: null,\n  plot: (K, p, w, d) => batteries(K, p, w, (d as typeof data | undefined) ?? data),\n  tip,\n  update,\n  describe: {\n    title: \"Fleet charge\",\n    summary: `Charge of ${data.items.length} vans: ${low.length} under 25% (${low.map((q) => q.label + \" \" + q.v + \"%\").join(\", \")}), ${data.items.filter((q) => q.charging).length} charging.`,\n    table: { head: [\"Van\", \"Charge\", \"Range\", \"Charging\"], rows: data.items.map((q) => [q.label, q.v + \"%\", km(q.sub), q.charging ? \"Yes\" : \"No\"]) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "compare-items"
  ],
  "meta": {
    "access": "free",
    "no": 78,
    "family": "Compare items"
  }
}
