{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gains-curve",
  "type": "registry:component",
  "title": "Gains curve",
  "description": "How much a model finds in its top picks. Sample data: a churn model, the top 20% of accounts hold 61% of churners.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-curve-ref"
  ],
  "files": [
    {
      "path": "registry/chartory/components/gains-curve.tsx",
      "type": "registry:component",
      "target": "components/chartory/gains-curve.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Gains curve (Chartory chart 060): 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/gains-curve\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/060-gains-curve/data\"\nimport { def } from \"@/lib/chartory/charts/types/060-gains-curve/layout\"\n\nregisterChart(def, sample)\n\nexport type GainsCurveData = typeof sample\nexport type GainsCurveProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: GainsCurveData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: GainsCurveData[]\n}\n\nexport function GainsCurve(props: GainsCurveProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/060-gains-curve/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/060-gains-curve/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 060 Churn model lift · sample data (Figma chart/060, from the Figma definition, seeded values expanded).\nimport type { CurveRefData } from \"../../plots/curve-ref\";\n\nexport const data: CurveRefData = {\n  mode: \"gains\",\n  k: 4.2,\n  mark: { x: 0.2, text: \"TOP 20% → 61% OF CHURNERS\" },\n  ticks: [\"100%\", \"75%\", \"50%\", \"25%\", \"0\"],\n  xt: [\n    [0, \"0\"],\n    [0.25, \"25%\"],\n    [0.5, \"50%\"],\n    [0.75, \"75%\"],\n    [1, \"100%\"]\n  ]\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/060-gains-curve/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/060-gains-curve/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 060 Gains curve (Figma chart/060, \"Churn model lift\"): C.curveRef in gains mode against the random diagonal.\nimport type { ChartDef } from \"../../core/shell\";\nimport { curveRef } from \"../../plots/curve-ref\";\nimport { data } from \"./data\";\n\nconst gain = (t: number) => 1 - Math.pow(1 - t, data.k);\nconst pct = (v: number) => Math.round(v * 100) + \"%\";\n\nexport const def: ChartDef = {\n  no: 60,\n  slug: \"gains-curve\",\n  legend: [[\"data/primary\", \"Model\"], [\"text/action\", \"Random\"]],\n  plot: (K, p, w, d) => curveRef(K, p, w, (d as typeof data | undefined) ?? data),\n  // the model retrained: the curve's steepness changes; the mark's chip is recomputed from the new curve\n  update: (d, step) => {\n    const o = d as typeof data, k = +(o.k + [-0.4, 0.3, 0.7][(step - 1) % 3]).toFixed(1);\n    return { ...o, k, mark: { ...o.mark, text: `TOP ${pct(o.mark.x)} → ${pct(1 - Math.pow(1 - o.mark.x, k))} OF CHURNERS` } };\n  },\n  describe: {\n    title: \"Churn model lift\",\n    summary: `Share of churners found against the share of customers contacted, ranked by the churn model: the top 20% reach ${pct(gain(0.2))} of churners, against 20% at random.`,\n    table: { head: [\"Customers contacted\", \"Churners found (model)\", \"Churners found (random)\"], rows: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1].map((t) => [pct(t), pct(gain(t)), pct(t)]) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "distribution"
  ],
  "meta": {
    "access": "free",
    "no": 60,
    "family": "Distribution"
  }
}
