import { GroupedBarChart, type BarSeries } from "@/components/charts/GroupedBarChart"; import { TooltipRow } from "@/components/charts/ChartTooltip"; import { useMoney } from "@/hooks/useMoney"; import type { CashflowPoint } from "./cashflow-data"; const SERIES: BarSeries<"income" | "expenses">[] = [ { key: "income", label: "Income", colorVar: "--series-income" }, { key: "expenses", label: "Expenses", colorVar: "--series-expense" }, ]; const getLabel = (d: CashflowPoint) => d.label; const getValue = (d: CashflowPoint, key: "income" | "expenses") => d[key]; /** * Income vs expenses per month. * * Two series, so this is the one genuinely categorical chart in the app. The * green/red pair is inherently the worst case for red-green colour blindness * (validated ΔE 6.7–7.2, inside the 6–8 floor band), which is legal only with * secondary encoding, hence the always-present legend, the gap between paired * bars, and the value labels in the tooltip. */ export function CashflowChart({ data }: { data: CashflowPoint[] }) { const { money, compact } = useMoney(); if (data.length === 0) { return
No transactions to chart.
; } return ({d.label}