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))})`; }; export const formatLabel = (label: string, type: string) => { if (type === "monthly") return label; if (type === "weekly") { const parts = label.split(" - "); if (parts.length === 2) { const [start, end] = parts; const startDay = start.split(" ")[0]; const [endDay, month] = end.split(" "); return `${startDay}–${endDay} ${month}`; } } return label; };