{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "deal-pipeline",
  "type": "registry:component",
  "title": "Deal pipeline",
  "description": "Value at each stage, and how fresh it is. Sample data: open pipeline from lead ($120K) to won ($122K), fresh, aging 21+ days and stuck 45+ days.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-pipeline"
  ],
  "files": [
    {
      "path": "registry/chartory/components/deal-pipeline.tsx",
      "type": "registry:component",
      "target": "components/chartory/deal-pipeline.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Deal pipeline (Chartory chart 083): 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/deal-pipeline\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/083-deal-pipeline/data\"\nimport { def } from \"@/lib/chartory/charts/types/083-deal-pipeline/layout\"\n\nregisterChart(def, sample)\n\nexport type DealPipelineData = typeof sample\nexport type DealPipelineProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: DealPipelineData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: DealPipelineData[]\n}\n\nexport function DealPipeline(props: DealPipelineProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/083-deal-pipeline/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/083-deal-pipeline/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 083 Deal pipeline · sample data (Figma chart/083-pipeline-deals).\nimport type { PipelineData } from \"../../plots/pipeline\";\n\nexport const data: PipelineData = {\n  fmt: (v) => \"$\" + v + \"K\",\n  stages: [{ label: \"LEAD\", deals: [[24, 5], [18, 12], [30, 8], [12, 30], [20, 3], [16, 50]] }, { label: \"QUALIFIED\", deals: [[40, 10], [22, 25], [35, 6], [18, 48]] }, { label: \"DEMO\", deals: [[60, 14], [28, 22], [45, 9]] }, { label: \"PROPOSAL\", deals: [[85, 18], [40, 33]] }, { label: \"WON\", deals: [[70, 2], [52, 4]] }],\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/083-deal-pipeline/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/083-deal-pipeline/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 083 Deal pipeline (Figma chart/083-pipeline-deals): C.pipeline, open deals per stage coloured by age.\nimport type { ChartDef, TooltipSpec } from \"../../core/shell\";\nimport { pipeline } from \"../../plots/pipeline\";\nimport { data } from \"./data\";\n\nconst age = (d: number) => (d > 45 ? \"Stuck 45+ d\" : d > 21 ? \"Aging 21+ d\" : \"Fresh\");\nconst all = data.stages.flatMap((s) => s.deals);\n\nconst wob = (i: number, step: number) => Math.sin(i * 2.1 + step * 1.7 + 0.4);\n/** A later week: deal values are re-scoped (whole $K), ages kept; the stage totals follow in the plot. */\nfunction update(d0: unknown, step: number): typeof data {\n  const d = d0 as typeof data;\n  let k = 0;\n  return { ...d, stages: d.stages.map((s) => ({ ...s, deals: s.deals.map(([v, a]): [number, number] => [Math.max(4, Math.round(v * (1 + 0.18 * wob(k++, step)))), a]) })) };\n}\n\n/** Hover: one stage (its deals and total): value per age state, the stage total. */\nfunction tip(d0: unknown, g: number): TooltipSpec | null {\n  const d = d0 as typeof data, s = d.stages[g];\n  if (!s) return null;\n  const states: [string, string, (a: number) => boolean][] = [[\"data/cat-2\", \"Fresh\", (a) => a <= 21], [\"status/warning\", \"Aging 21+ d\", (a) => a > 21 && a <= 45], [\"status/danger\", \"Stuck 45+ d\", (a) => a > 45]];\n  const rows = states.flatMap(([swatch, label, f]) => {\n    const ds = s.deals.filter((x) => f(x[1]));\n    return ds.length ? [{ label: `${label} · ${ds.length}`, value: d.fmt(ds.reduce((a, x) => a + x[0], 0)), swatch }] : [];\n  });\n  return { kind: \"series\", caps: `${s.label} · ${s.deals.length} DEALS`, rows, total: { label: \"Stage total\", value: d.fmt(s.deals.reduce((a, x) => a + x[0], 0)) } };\n}\n\nexport const def: ChartDef = {\n  no: 83,\n  slug: \"deal-pipeline\",\n  legend: [[\"data/cat-2\", \"Fresh\"], [\"status/warning\", \"Aging 21+ d\"], [\"status/danger\", \"Stuck 45+ d\"]],\n  plot: (K, p, w, d) => pipeline(K, p, w, (d as typeof data | undefined) ?? data),\n  tip,\n  update,\n  describe: {\n    title: \"Deal pipeline\",\n    summary: `${all.length} deals worth ${data.fmt(all.reduce((a, d) => a + d[0], 0))} across ${data.stages.length} stages: ${data.stages.map((s) => `${s.label.toLowerCase()} ${data.fmt(s.deals.reduce((a, d) => a + d[0], 0))}`).join(\", \")}; ${all.filter((d) => d[1] > 45).length} deals stuck 45+ days.`,\n    table: { head: [\"Stage\", \"Value\", \"Age (days)\", \"State\"], rows: data.stages.flatMap((s) => s.deals.map(([v, d]) => [s.label, data.fmt(v), d, age(d)])) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "flow-between-steps"
  ],
  "meta": {
    "access": "free",
    "no": 83,
    "family": "Flow between steps"
  }
}
