{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "forecast-band",
  "type": "registry:component",
  "title": "Forecast band",
  "description": "Where it is heading, and how sure we are. Sample data: cash on hand, May to April, actual to October, P10–P90 band.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-band"
  ],
  "files": [
    {
      "path": "registry/chartory/components/forecast-band.tsx",
      "type": "registry:component",
      "target": "components/chartory/forecast-band.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Forecast band (Chartory chart 015): 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/forecast-band\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/015-forecast-band/data\"\nimport { def } from \"@/lib/chartory/charts/types/015-forecast-band/layout\"\n\nregisterChart(def, sample)\n\nexport type ForecastBandData = typeof sample\nexport type ForecastBandProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: ForecastBandData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: ForecastBandData[]\n}\n\nexport function ForecastBand(props: ForecastBandProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/015-forecast-band/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/015-forecast-band/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 015 · sample data (Figma chart/015-forecast-band, fintech: cash balance in $M, actual to October, forecast with a p10–p90 band to April; band = mid ± 0.02 to today, then +0.07 per month).\nimport type { BandData } from \"../../plots/band\";\n\nexport const data: BandData = {\n  mid: [2.1, 2.2, 2.15, 2.3, 2.35, 2.41, 2.46, 2.5, 2.52, 2.58, 2.6, 2.66],\n  hi: [2.12, 2.22, 2.17, 2.32, 2.37, 2.43, 2.53, 2.64, 2.73, 2.8600000000000003, 2.95, 3.08],\n  lo: [2.08, 2.18, 2.13, 2.28, 2.33, 2.39, 2.39, 2.36, 2.31, 2.3, 2.25, 2.24],\n  split: 5,\n  min: 1.8,\n  max: 3.2,\n  ticks: [\"3.2M\", \"2.7M\", \"2.3M\", \"1.8M\"],\n  xl: { 0: \"MAY\", 5: \"OCT\", 11: \"APR\" },\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/015-forecast-band/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/015-forecast-band/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 015 Forecast band (Figma chart/015-forecast-band): C.band on the cash balance (actual, forecast, p10–p90).\nimport type { ChartDef } from \"../../core/shell\";\nimport { band } from \"../../plots/band\";\nimport { data } from \"./data\";\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst r2 = (v: number) => Math.round(v * 100) / 100;\n\nconst months = [\"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\", \"Jan\", \"Feb\", \"Mar\", \"Apr\"];\nconst m = (v: number) => \"$\" + (Math.round(v * 100) / 100).toFixed(2) + \"M\";\n\nexport const def: ChartDef = {\n  no: 15,\n  slug: \"forecast-band\",\n  legend: [[\"data/primary\", \"Actual\"], [\"data/primary-soft\", \"Forecast\"]],\n  plot: (K, p, w, d) => band(K, p, w, (d as typeof data | undefined) ?? data),\n  update: (d, step) => {\n    const o = d as typeof data;\n    // a later run: the balance moves up to ±$0.06M on a swell plus a small upward drift; the p10–p90 band keeps its\n    // width around it (clipped inside the 1.8M–3.2M axis)\n    const mid = o.mid.map((v, i) => r2(v + 0.06 * Math.sin(i * 0.6 + step * 2.1) + (0.02 * step * i) / (o.mid.length - 1)));\n    return {\n      ...o, mid,\n      hi: mid.map((m, i) => clamp(r2(m + o.hi[i] - o.mid[i]), m, o.max - 0.02)),\n      lo: mid.map((m, i) => clamp(r2(m - (o.mid[i] - o.lo[i])), o.min + 0.02, m)),\n    };\n  },\n  describe: {\n    title: \"Cash balance forecast\",\n    summary: `Cash balance from May to October (actual, ${m(data.mid[5])} today) and forecast to April: ${m(data.mid[11])}, with a p10–p90 band of ${m(data.lo[11])} to ${m(data.hi[11])}.`,\n    table: { head: [\"Month\", \"Balance\", \"P10\", \"P90\", \"Kind\"], rows: months.map((mo, i) => [mo, m(data.mid[i]), m(data.lo[i]), m(data.hi[i]), i <= data.split ? \"Actual\" : \"Forecast\"]) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "change-over-time"
  ],
  "meta": {
    "access": "free",
    "no": 15,
    "family": "Change over time"
  }
}
