From 38eb48cd2eda1b7fe455bec698fcadc0ed9c1bb7 Mon Sep 17 00:00:00 2001 From: Kipstz Avenger <140314732+Kipstz@users.noreply.github.com> Date: Fri, 1 Aug 2025 00:34:22 +0200 Subject: [PATCH] Fix for two formatPercentage functions (#1659) Closes #1656 ## Description: Change: Simplification of the function to display percentages with one decimal place without limitation. Result: Percentages are now displayed with one rounded decimal place (e.g. 15.5%, 99.6%) without automatic replacement of extreme values. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I have read and accepted the CLA agreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: kipstzz --- src/client/graphics/layers/Leaderboard.ts | 5 +---- src/client/graphics/layers/TeamStats.ts | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/client/graphics/layers/Leaderboard.ts b/src/client/graphics/layers/Leaderboard.ts index 1a1fe641b..513aa2711 100644 --- a/src/client/graphics/layers/Leaderboard.ts +++ b/src/client/graphics/layers/Leaderboard.ts @@ -269,9 +269,6 @@ export class Leaderboard extends LitElement implements Layer { function formatPercentage(value: number): string { const perc = value * 100; - if (perc > 99.5) return "100%"; - if (perc < 0.01) return "0%"; - if (perc < 0.1) return perc.toPrecision(1) + "%"; if (Number.isNaN(perc)) return "0%"; - return perc.toPrecision(2) + "%"; + return perc.toFixed(1) + "%"; } diff --git a/src/client/graphics/layers/TeamStats.ts b/src/client/graphics/layers/TeamStats.ts index 16251a0ad..687d807c6 100644 --- a/src/client/graphics/layers/TeamStats.ts +++ b/src/client/graphics/layers/TeamStats.ts @@ -167,8 +167,6 @@ export class TeamStats extends LitElement implements Layer { function formatPercentage(value: number): string { const perc = value * 100; - if (perc > 99.5) return "100%"; - if (perc < 0.01) return "0%"; - if (perc < 0.1) return perc.toPrecision(1) + "%"; + if (Number.isNaN(perc)) return "0%"; return perc.toPrecision(2) + "%"; }