"use client"; import { motion } from "motion/react"; import { ChartFrame } from "./chart-frame"; import { treemapLayout, type TreemapItemIn } from "@/lib/layout"; import { seqRamp } from "@/lib/chart-utils"; type TreemapProps = { data: TreemapItemIn[]; width?: number; height?: number; className?: string; }; /** Treemap — rects (deterministic binary split) scale in from their own center, staggered by area. */ export function Treemap({ data, width = 640, height = 380, className }: TreemapProps) { const rects = treemapLayout(data, width, height); const max = Math.max(...data.map((d) => d.value), 1); return ( {({ inView, reduce }) => ( <> {rects.map((r, i) => { const cx = r.x + r.w / 2; const cy = r.y + r.h / 2; const t = r.value / max; return ( {r.w > 70 && r.h > 34 && ( 0.6 ? "var(--ink-900)" : "var(--ink-800)"} initial={{ opacity: 0 }} animate={inView ? { opacity: 1 } : { opacity: 0 }} transition={{ duration: 0.3, delay: 0.1 + i * 0.06 + 0.35 }} > {r.label ?? r.id} )} ); })} )} ); }