mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 15:30:43 +00:00
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:
@@ -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) + "%";
|
||||
}
|
||||
|
||||
@@ -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) + "%";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user