import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts'; import './PriceChart.css'; interface PriceChartProps { data: Array<{ timestamp: number; price: number }>; currentPrice: number; } export const PriceChart = ({ data, currentPrice }: PriceChartProps) => { if (!data || data.length === 0) { return (
Collecting price data...
); } // Determine if price is trending up or down const firstPrice = data[0]?.price || currentPrice; const priceChange = ((currentPrice - firstPrice) / firstPrice) * 100; const lineColor = priceChange >= 0 ? '#00ff88' : '#ff3366'; // Format data for chart const chartData = data.map(point => ({ time: new Date(point.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }), price: point.price })); return (
Price Trend = 0 ? 'positive' : 'negative'}`}> {priceChange >= 0 ? '+' : ''}{priceChange.toFixed(2)}%
); };