"use client"; import { motion } from "motion/react"; import { ChartFrame } from "@/components/charts/chart-frame"; import { sankeyLayout, type SankeyNodeIn, type SankeyLinkIn } from "@/lib/layout"; import { catColor } from "@/lib/chart-utils"; type SankeyProps = { columns: string[][]; nodes: SankeyNodeIn[]; links: SankeyLinkIn[]; width?: number; height?: number; className?: string; }; /** Sankey — flows whose width encodes value. Nodes fade in by column; links draw (pathLength) as strokes. */ export function Sankey({ columns, nodes, links, width = 720, height = 400, className }: SankeyProps) { const M = 12; const layout = sankeyLayout(columns, nodes, links, width - M * 2, height - M * 2); const lastCol = columns.length - 1; const colOf = new Map(); columns.forEach((col, ci) => col.forEach((id) => colOf.set(id, ci))); return ( {({ inView, reduce }) => ( {layout.links.map((l, i) => ( ))} {layout.nodes.map((n) => { const ci = colOf.get(n.id) ?? 0; const labelLeft = ci === lastCol; return ( {n.label} ); })} )} ); }