import { useTranslation } from "react-i18next"; import { BarChart, Bar, XAxis, YAxis, Cell, ReferenceLine, Tooltip, ResponsiveContainer } from "recharts"; import type { HighlightMover } from "../../shared/types"; import { ChartPatternDefs, getPatternFill } from "../../utils/chartPatterns"; export interface HighlightsTopMoversChartProps { movers: HighlightMover[]; } function formatCurrency(amount: number, language: string): string { return new Intl.NumberFormat(language === "fr" ? "fr-CA" : "en-CA", { style: "currency", currency: "CAD", maximumFractionDigits: 0, }).format(amount); } export default function HighlightsTopMoversChart({ movers }: HighlightsTopMoversChartProps) { const { t, i18n } = useTranslation(); if (movers.length === 0) { return (
{t("reports.empty.noData")}
); } const chartData = movers .map((m, i) => ({ name: m.categoryName, color: m.categoryColor, delta: m.deltaAbs, index: i, })) .sort((a, b) => a.delta - b.delta); return (
({ color: d.color, index: d.index }))} /> formatCurrency(v, i18n.language)} stroke="var(--muted-foreground)" fontSize={11} /> typeof value === "number" ? formatCurrency(value, i18n.language) : String(value) } contentStyle={{ backgroundColor: "var(--card)", border: "1px solid var(--border)", borderRadius: "0.5rem", }} /> {chartData.map((entry) => ( ))}
); }