import { useTranslation } from "react-i18next"; import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, Legend, CartesianGrid, } from "recharts"; import type { CategoryOverTimeData } from "../../shared/types"; const eurFormatter = (value: number) => new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(value); function formatMonth(month: string): string { const [year, m] = month.split("-"); const date = new Date(Number(year), Number(m) - 1); return date.toLocaleDateString("default", { month: "short", year: "2-digit" }); } interface CategoryOverTimeChartProps { data: CategoryOverTimeData; } export default function CategoryOverTimeChart({ data }: CategoryOverTimeChartProps) { const { t } = useTranslation(); if (data.data.length === 0) { return (

{t("dashboard.noData")}

); } return (
eurFormatter(v)} tick={{ fill: "var(--muted-foreground)", fontSize: 12 }} stroke="var(--border)" width={80} /> eurFormatter(value ?? 0)} labelFormatter={(label) => formatMonth(String(label))} contentStyle={{ backgroundColor: "var(--card)", border: "1px solid var(--border)", borderRadius: "8px", }} /> {data.categories.map((name) => ( ))}
); }