amount formatter
This commit is contained in:
@@ -34,6 +34,23 @@ export default function HistoryChart({
|
|||||||
|
|
||||||
const maxAmount = Math.max(...currentData.map((d) => d.amount), 1);
|
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 (
|
return (
|
||||||
<Paper sx={{ p: { xs: 2, sm: 4 }, borderRadius: 4, width: "100%", boxShadow: 'none', border: '1px solid', borderColor: 'divider' }}>
|
<Paper sx={{ p: { xs: 2, sm: 4 }, borderRadius: 4, width: "100%", boxShadow: 'none', border: '1px solid', borderColor: 'divider' }}>
|
||||||
<Typography variant="h6" fontWeight={700} gutterBottom>
|
<Typography variant="h6" fontWeight={700} gutterBottom>
|
||||||
@@ -94,9 +111,9 @@ export default function HistoryChart({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="caption" sx={{ mb: 1, opacity: 0.7, fontSize: '0.65rem', display: { xs: 'none', sm: 'block' } }}>
|
<Typography variant="caption" sx={{ mb: 1, opacity: 0.7, fontSize: '0.65rem', display: { xs: 'none', sm: 'block' } }}>
|
||||||
{point.amount > 0 ? `Rs ${point.amount}` : ''}
|
{point.amount > 0 ? formatAmount(point.amount) : ""}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: "40%",
|
width: "40%",
|
||||||
@@ -112,7 +129,7 @@ export default function HistoryChart({
|
|||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Typography variant="caption" color="text.secondary" sx={{ mt: 1, fontWeight: 500, fontSize: '0.7rem' }}>
|
<Typography variant="caption" color="text.secondary" sx={{ mt: 1, fontWeight: 500, fontSize: '0.7rem' }}>
|
||||||
{point.id}
|
{point.id}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
Reference in New Issue
Block a user