'use client'; /** * Sparkline — Tiny inline area chart for KPI cards. * * Features: * - Uses Recharts in * - Default size: 80×32px * - No axes, no grid, no tooltip — pure visual indicator * - Gradient fill matching the trend color * - Unique gradient ID to avoid conflicts with multiple sparklines * * Requirements: 4.1, 4.3, 4.4 */ import { useId } from 'react'; import { AreaChart, Area, ResponsiveContainer } from 'recharts'; export interface SparklineProps { data: number[]; color: string; width?: number; height?: number; } export default function Sparkline({ data, color, width = 80, height = 32, }: SparklineProps) { const uniqueId = useId(); const gradientId = `sparkline-gradient-${uniqueId}`; // Transform number[] into the format Recharts expects const chartData = data.map((value, index) => ({ index, value })); if (data.length === 0) { return null; } return (
); }