diff --git a/ui/src/components/shared/Sparkline.tsx b/ui/src/components/shared/Sparkline.tsx deleted file mode 100644 index 025e7a36..00000000 --- a/ui/src/components/shared/Sparkline.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { useMemo, useRef } from 'react'; - -interface SparklineProps { - data: number[]; - color: string; -} - -export function Sparkline({ data, color }: SparklineProps) { - const gradientIdRef = useRef('spark-' + Math.random().toString(36).slice(2, 9)); - const gradientId = gradientIdRef.current; - - // Drop first and last buckets — they are partial time windows and skew the trend - const trimmed = useMemo(() => (data.length > 4 ? data.slice(1, -1) : data), [data]); - - const { linePath, fillPath } = useMemo(() => { - if (trimmed.length < 2) return { linePath: '', fillPath: '' }; - - const w = 200; - const h = 24; - const max = Math.max(...trimmed); - const min = Math.min(...trimmed); - const range = max - min || 1; - const step = w / (trimmed.length - 1); - - const points = trimmed.map( - (v, i) => `${i * step},${h - ((v - min) / range) * (h - 2) - 1}`, - ); - - return { - linePath: points.join(' '), - fillPath: `0,${h} ${points.join(' ')} ${w},${h}`, - }; - }, [trimmed]); - - if (trimmed.length < 2) return null; - - return ( -
- - - - - - - - - - -
- ); -}