import React from 'react'; import { View } from 'react-native'; import Svg, { Polyline, Defs, LinearGradient, Stop, Rect } from 'react-native-svg'; interface SparklineProps { data: number[]; width?: number; height?: number; color?: string; strokeWidth?: number; } export default function Sparkline({ data, width = 100, height = 40, color = '#00ff88', strokeWidth = 1.5, }: SparklineProps) { if (!data || data.length < 2) return null; const min = Math.min(...data); const max = Math.max(...data); const range = max - min || 1; const padding = 2; const points = data .map((val, i) => { const x = (i / (data.length - 1)) * (width - padding * 2) + padding; const y = height - padding - ((val - min) / range) * (height - padding * 2); return `${x},${y}`; }) .join(' '); return ( ); }