import { useTranslation } from "react-i18next"; import { AreaChart, Area, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid, } from "recharts"; import type { MonthlyTrendItem } from "../../shared/types"; const cadFormatter = (value: number) => new Intl.NumberFormat("en-CA", { style: "currency", currency: "CAD", 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 MonthlyTrendsChartProps { data: MonthlyTrendItem[]; } export default function MonthlyTrendsChart({ data }: MonthlyTrendsChartProps) { const { t } = useTranslation(); if (data.length === 0) { return (

{t("dashboard.noData")}

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