import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts"; import { useTranslation } from "react-i18next"; import { useLocaleFormatters } from "~/locale/format"; import { formatMonthLabel } from "./dashboardFormatters"; export type DashboardMonthlySeriesChartProps = { /** `id` is an ISO month (`2026-07`); the label is formatted for the viewer's locale. */ points: readonly { id: string; value: number; comparisonValue?: number }[]; valueFormat: "currency" | "count"; hasComparison: boolean; }; /** * Lazily loaded visual enhancement. Columns, not bars: time runs left to right * (IBCS). The current period is the solid, saturated series and the previous * year is the lighter one behind it — the only two encodings on the chart, so a * reader can tell "now" from "then" without decoding a colour key. * * The parent card owns the accessible summary and data table, so this SVG is * hidden from assistive technology. */ export default function DashboardMonthlySeriesChart({ points, valueFormat, hasComparison }: DashboardMonthlySeriesChartProps) { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const formatValue = (value: number) => valueFormat === "currency" ? formatters.currency(value, "EUR", { maximumFractionDigits: 0 }) : formatters.number(value, { maximumFractionDigits: 0 }); const data = points.map((point) => ({ ...point, label: formatMonthLabel(point.id, formatters.locale), })); return (
); }