"use client"; import { useMemo } from "react"; import { ArrowDown, ArrowUp } from "lucide-react"; import clsx from "clsx"; interface ChartPoint { time: string; value: number; } interface MarketChartProps { symbol: string; data: ChartPoint[]; change: number; } export function MarketChart({ symbol, data, change }: MarketChartProps) { const isPositive = change >= 0; // Calculate min and max for chart scaling const { path } = useMemo(() => { if (!data.length) return { path: "" }; const minValue = Math.min(...data.map(d => d.value)); const maxValue = Math.max(...data.map(d => d.value)); const range = maxValue - minValue; const padding = range * 0.1; // Add 10% padding // Chart dimensions const width = 1000; const height = 300; // Scale points to fit the chart const points = data.map((point, i) => { const x = (i / (data.length - 1)) * width; const y = height - ((point.value - (minValue - padding)) / (range + 2 * padding)) * height; return `${x},${y}`; }); return { path: `M ${points.join(" L ")}`, }; }, [data]); const currentPrice = data[data.length - 1]?.value; const timeRange = "24H"; return (