import { useTranslation } from "react-i18next"; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from "recharts"; import type { CategoryZoomEvolutionPoint } from "../../shared/types"; export interface CategoryEvolutionChartProps { data: CategoryZoomEvolutionPoint[]; color?: string; } 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" }); } export default function CategoryEvolutionChart({ data, color = "var(--primary)", }: CategoryEvolutionChartProps) { const { t, i18n } = useTranslation(); if (data.length === 0) { return (
{t("reports.empty.noData")}
); } return (

{t("reports.category.evolution")}

new Intl.NumberFormat(i18n.language === "fr" ? "fr-CA" : "en-CA", { style: "currency", currency: "CAD", maximumFractionDigits: 0, }).format(v) } /> typeof value === "number" ? new Intl.NumberFormat(i18n.language === "fr" ? "fr-CA" : "en-CA", { style: "currency", currency: "CAD", }).format(value) : String(value) } labelFormatter={(label) => (typeof label === "string" ? formatMonth(label) : String(label ?? ""))} contentStyle={{ backgroundColor: "var(--card)", border: "1px solid var(--border)", borderRadius: "0.5rem", }} />
); }