From 234f86d6b940b8ffcf5e714631f28b570eb4bef5 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Mon, 6 Apr 2026 16:10:09 +0530 Subject: [PATCH] amount formatter --- src/components/HistoryChart.tsx | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/HistoryChart.tsx b/src/components/HistoryChart.tsx index 2f0cd75..e0658e4 100644 --- a/src/components/HistoryChart.tsx +++ b/src/components/HistoryChart.tsx @@ -34,6 +34,23 @@ export default function HistoryChart({ const maxAmount = Math.max(...currentData.map((d) => d.amount), 1); + // ✅ Formatter (₹ + adaptive units) + const formatAmount = (amount: number) => { + const tab = activeTab.toLowerCase(); + + if (tab === "year") { + const lakhs = amount / 100000; + return `₹ ${lakhs.toFixed(2)} L`; + } + + if (tab === "month") { + const thousands = amount / 1000; + return `₹ ${thousands.toFixed(1)} K`; + } + + return `₹ ${amount.toLocaleString("en-IN")}`; + }; + return ( @@ -94,9 +111,9 @@ export default function HistoryChart({ }} > - {point.amount > 0 ? `Rs ${point.amount}` : ''} + {point.amount > 0 ? formatAmount(point.amount) : ""} - + - + {point.id}