'use client' import { FMResult } from '@/lib/types' import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, ReferenceLine, Cell, } from 'recharts' interface WaterfallChartProps { results: FMResult[] lang: 'de' | 'en' } export default function WaterfallChart({ results, lang }: WaterfallChartProps) { // Sample quarterly data for cleaner display const quarterlyData = results.filter((_, i) => i % 3 === 0).map((r) => { const netCash = r.revenue_eur - r.total_costs_eur return { label: `${r.year.toString().slice(2)}/Q${Math.ceil(r.month_in_year / 3)}`, month: r.month, revenue: Math.round(r.revenue_eur), costs: Math.round(-r.total_costs_eur), net: Math.round(netCash), cashBalance: Math.round(r.cash_balance_eur), } }) const formatValue = (value: number) => { if (Math.abs(value) >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M` if (Math.abs(value) >= 1_000) return `${(value / 1_000).toFixed(0)}k` return value.toString() } return (
[ formatValue(value) + ' EUR', name === 'revenue' ? (lang === 'de' ? 'Umsatz' : 'Revenue') : name === 'costs' ? (lang === 'de' ? 'Kosten' : 'Costs') : 'Net', ]} /> {quarterlyData.map((entry, i) => ( ))} {quarterlyData.map((entry, i) => ( ))}
) }