{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "correlation-triangle",
  "type": "registry:component",
  "title": "Correlation triangle",
  "description": "How every pair moves together. Sample data: six coins, tightest ETH · BTC 0.86, loosest TON · SOL −0.06.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-corr-tri"
  ],
  "files": [
    {
      "path": "registry/chartory/components/correlation-triangle.tsx",
      "type": "registry:component",
      "target": "components/chartory/correlation-triangle.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Correlation triangle (Chartory chart 085): 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/correlation-triangle\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/085-correlation-triangle/data\"\nimport { def } from \"@/lib/chartory/charts/types/085-correlation-triangle/layout\"\n\nregisterChart(def, sample)\n\nexport type CorrelationTriangleData = typeof sample\nexport type CorrelationTriangleProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: CorrelationTriangleData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: CorrelationTriangleData[]\n}\n\nexport function CorrelationTriangle(props: CorrelationTriangleProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/085-correlation-triangle/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/085-correlation-triangle/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 085 Asset correlation · sample data (Figma chart/085-correlation-crypto).\nimport type { CorrTriData } from \"../../plots/corr-tri\";\n\nexport const data: CorrTriData = {\n  labels: [\"BTC\", \"ETH\", \"SOL\", \"XRP\", \"ADA\", \"TON\"],\n  m: [[1], [0.86, 1], [0.74, 0.79, 1], [0.52, 0.48, 0.41, 1], [0.63, 0.58, 0.61, 0.37, 1], [0.12, 0.08, -0.06, 0.15, -0.11, 1]],\n  rows: [{ label: \"Tightest\", text: \"ETH · BTC\", pct: \"0.86\" }, { label: \"Loosest\", text: \"TON · SOL\", pct: \"−0.06\" }, { label: \"Hedge\", text: \"TON\", pct: \"LOW TO BTC\" }],\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/085-correlation-triangle/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/085-correlation-triangle/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 085 Correlation triangle (Figma chart/085-correlation-crypto): C.corrTri on six coins, 30-day daily returns.\nimport type { ChartDef } from \"../../core/shell\";\nimport { corrTri } from \"../../plots/corr-tri\";\nimport { data } from \"./data\";\n\nconst fmt = (r: number) => (r < 0 ? \"−\" : \"\") + Math.abs(r).toFixed(2);\n\n/** A later 30 days: every pair drifts a little (sign kept), the tightest and loosest pairs recomputed. */\nfunction update(d0: unknown, step: number): typeof data {\n  const d = d0 as typeof data;\n  let k = 0;\n  const m = d.m.map((row, i) => row.map((r, j) => {\n    if (i === j) return r;\n    const v = +(r + 0.05 * Math.sin(k++ * 2.1 + step * 1.7 + 0.4)).toFixed(2);\n    return r >= 0 ? Math.min(0.97, Math.max(0.01, v)) : Math.max(-0.97, Math.min(-0.01, v));\n  }));\n  const pairs = m.flatMap((row, i) => row.slice(0, i).map((r, j) => ({ r, name: d.labels[i] + \" · \" + d.labels[j] })));\n  const hi = pairs.reduce((a, b) => (b.r > a.r ? b : a)), lo = pairs.reduce((a, b) => (Math.abs(b.r) < Math.abs(a.r) ? b : a));\n  return { ...d, m, rows: [{ ...d.rows[0], text: hi.name, pct: fmt(hi.r) }, { ...d.rows[1], text: lo.name, pct: fmt(lo.r) }, d.rows[2]] };\n}\n\nexport const def: ChartDef = {\n  no: 85,\n  slug: \"correlation-triangle\",\n  legend: [[\"data/primary\", \"Move together\"], [\"data/cat-2\", \"Move apart\"]],\n  flat: [\"s\"],\n  plot: (K, p, w, d) => corrTri(K, p, w, (d as typeof data | undefined) ?? data),\n  update,\n  describe: {\n    title: \"Asset correlation\",\n    summary: `Correlation of daily returns over 30 days for ${data.labels.join(\", \")}: tightest ETH and BTC (0.86), loosest TON and SOL (−0.06).`,\n    table: { head: [\"\", ...data.labels], rows: data.labels.map((l, i) => [l, ...data.labels.map((_, j) => (j <= i ? fmt(data.m[i][j]) : \"\"))]) },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "relationship"
  ],
  "meta": {
    "access": "free",
    "no": 85,
    "family": "Relationship"
  }
}
