import { useState, useMemo } from 'react'; import { ResponsiveContainer, LineChart, Line, XAxis, YAxis, Tooltip, ReferenceLine, CartesianGrid, } from 'recharts'; const SERIES = { treasury: { label: 'Treasury', accessor: r => r.treasury_after, color: '#7c5cff' }, total_revenue: { label: 'Revenue', accessor: r => r.total_revenue, color: '#2dd4bf' }, productivity: { label: 'Productivity', accessor: r => r.productivity, color: '#f6c177' }, prosperity: { label: 'Prosperity ×1e3', accessor: r => r.prosperity * 1000, color: '#60a5fa' }, population: { label: 'Population', accessor: r => r.population, color: '#fb923c' }, reward_total: { label: 'Reward (step)', accessor: r => r.reward.total, color: '#4ade80' }, cumulative_reward: { label: 'Cumulative reward', accessor: r => r.cumulative_reward, color: '#f472b6' }, total_allocation: { label: 'Total allocation', accessor: r => r.total_allocation, color: '#a78bfa' }, }; export default function TimeSeries({ rounds, currentRound }) { const [active, setActive] = useState(['treasury', 'total_revenue', 'cumulative_reward']); const data = useMemo(() => rounds.map(r => { const row = { round: r.round_num }; for (const [k, s] of Object.entries(SERIES)) { row[k] = s.accessor(r); } return row; }), [rounds]); const toggle = key => { setActive(prev => (prev.includes(key) ? prev.filter(k => k !== key) : [...prev, key])); }; return (