import { cx } from "@/lib/format"; /** Inline SVG sparkline (no library). Colour follows the sign of the series unless `stroke` is given. */ export function Sparkline({ values, width = 96, height = 28, className, stroke, fill = true }: { values: number[]; width?: number; height?: number; className?: string; stroke?: string; fill?: boolean }) { const pts = values.filter((v) => Number.isFinite(v)); if (pts.length < 2) return ; const min = Math.min(...pts); const max = Math.max(...pts); const span = max - min || 1; const step = width / (pts.length - 1); const coords = pts.map((v, i) => [i * step, height - 2 - ((v - min) / span) * (height - 4)] as const); const d = coords.map(([x, y], i) => `${i ? "L" : "M"}${x.toFixed(1)},${y.toFixed(1)}`).join(" "); const up = pts[pts.length - 1]! >= pts[0]!; const color = stroke ?? (up ? "var(--positive)" : "var(--negative)"); return ( ); }