From 8aaf6f7902d463a84af91a465de3800d6b81545b Mon Sep 17 00:00:00 2001 From: blaisadmin Date: Sun, 29 Mar 2026 22:34:12 -0400 Subject: [PATCH] single graph --- frontend/src/pages/Home.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index ae5adcc..808e88e 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -299,14 +299,18 @@ export default function Home() { [ammoPageCaliberIds, enabledCalibers], ); const ammoChartData = useMemo(() => { - const withRounds = enabledAmmoInventory - .filter((inventory) => inventory.roundsOnHand > 0) - .sort((left, right) => right.roundsOnHand - left.roundsOnHand); - const maxRounds = withRounds[0]?.roundsOnHand ?? 0; + const sortedInventory = [...enabledAmmoInventory].sort((left, right) => { + if (right.roundsOnHand !== left.roundsOnHand) { + return right.roundsOnHand - left.roundsOnHand; + } - return withRounds.map((inventory) => ({ + return left.caliber.localeCompare(right.caliber); + }); + const maxRounds = sortedInventory[0]?.roundsOnHand ?? 0; + + return sortedInventory.map((inventory) => ({ ...inventory, - widthPercent: maxRounds > 0 ? Math.max((inventory.roundsOnHand / maxRounds) * 100, 8) : 0, + widthPercent: maxRounds > 0 ? Math.max((inventory.roundsOnHand / maxRounds) * 100, inventory.roundsOnHand > 0 ? 8 : 0) : 0, })); }, [enabledAmmoInventory]); const firearmCategoryCounts = useMemo( @@ -1291,7 +1295,7 @@ export default function Home() { {ammoChartData.length === 0 ? ( -

Add rounds to a caliber to see how your inventory stacks up.

+

Enable calibers in Settings to see your ammo inventory chart.

) : (
{ammoChartData.map((inventory) => (