interface SparklineProps { values: number[]; className?: string; stroke?: string; } /** * Minimal SVG sparkline. Normalises to its own range, draws a stroked * line with a soft fill, and marks the last point. Uses * preserveAspectRatio="none" + non-scaling-stroke so the chart stretches * with its container without distorting the stroke. */ export function Sparkline({ values, className, stroke = "hsl(var(--accent))", }: SparklineProps) { if (!values || values.length < 2) return null; const w = 100; const h = 28; const min = Math.min(...values); const max = Math.max(...values); const range = max - min || 1; const pts = values.map((v, i) => { const x = (i / (values.length - 1)) * w; const y = h - ((v - min) / range) * (h - 4) - 2; return [x, y] as const; }); const line = pts .map((p, i) => `${i === 0 ? "M" : "L"}${p[0].toFixed(2)} ${p[1].toFixed(2)}`) .join(" "); const area = `${line} L ${w} ${h} L 0 ${h} Z`; const last = pts[pts.length - 1]!; return ( ); }