import { ChartDataPoint } from "./HistoryChart.models"; export const formatDisplay = ( point: ChartDataPoint, tab: string, comparison: boolean ) => { const base = point.amount; const cmp = point.compare?.amount ?? 0; const formatShort = (val: number) => { if (tab === "monthly" && val >= 100000) { return `${(val / 100000).toFixed(2)}L`; } if (tab === "weekly" && val >= 1000) { return `${(val / 1000).toFixed(1)}K`; } return val.toLocaleString("en-IN"); }; if (!comparison) return `₹ ${formatShort(base)}`; const diff = base - cmp; const sign = diff >= 0 ? "+" : "-"; return `₹ ${formatShort(base)} (${sign}${formatShort(Math.abs(diff))})`; };