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
This commit is contained in:
Kipstz Avenger
2025-08-01 00:34:22 +02:00
committed by GitHub
parent ebc0525c89
commit 38eb48cd2e
2 changed files with 2 additions and 7 deletions
+1 -4
View File
@@ -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) + "%";
}
+1 -3
View File
@@ -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) + "%";
}