"use client"; import { motion } from "motion/react"; import { ChartFrame } from "@/components/charts/chart-frame"; import { linearScale } from "@/lib/chart-utils"; export type GanttTask = { label: string; start: number; end: number }; type GanttChartProps = { tasks: GanttTask[]; /** Tick labels along the time axis (aligned to integer time units). */ ticks?: { at: number; label: string }[]; today?: number; width?: number; height?: number; className?: string; }; const M = { top: 28, right: 18, bottom: 12, left: 132 }; /** GanttChart — bars positioned on a time scale, growing scaleX from their start, staggered top→down. */ export function GanttChart({ tasks, ticks, today, width = 720, height, className }: GanttChartProps) { const min = Math.min(...tasks.map((t) => t.start)); const max = Math.max(...tasks.map((t) => t.end)); const sx = linearScale([min, max], [M.left, width - M.right]); const rowH = 34; const h = height ?? M.top + M.bottom + tasks.length * rowH; return ( {({ inView, reduce }) => ( <> {ticks?.map((t) => ( {t.label} ))} {today != null && ( )} {tasks.map((t, i) => { const y = M.top + i * rowH; const x0 = sx(t.start); const x1 = sx(t.end); return ( {t.label} ); })} )} ); }