import { useState } from 'react'; import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, Area, AreaChart } from 'recharts'; interface Props { data: { date: string; price: number }[]; } export default function PriceHistoryChart({ data }: Props) { const [range, setRange] = useState<30 | 90 | 365>(30); const filtered = data.slice(-range); const min = Math.floor(Math.min(...filtered.map(d => d.price)) - 5); const max = Math.ceil(Math.max(...filtered.map(d => d.price)) + 5); const ranges = [ { value: 30 as const, label: '30D' }, { value: 90 as const, label: '90D' }, { value: 365 as const, label: '1J' }, ]; return (

Prijsverloop

{ranges.map(r => ( ))}
{ const d = new Date(v); return `${d.getDate()}/${d.getMonth() + 1}`; }} axisLine={false} tickLine={false} interval="preserveStartEnd" /> `€${v}`} axisLine={false} tickLine={false} width={50} /> { const d = new Date(v); return d.toLocaleDateString('nl-NL', { day: 'numeric', month: 'long', year: 'numeric' }); }} formatter={(value: number) => [`€${value.toFixed(2).replace('.', ',')}`, 'Prijs']} />
); }