From ed3bebfcda5734d1d29ba232954488ac9bcfe78a Mon Sep 17 00:00:00 2001 From: Matteo Contrini Date: Fri, 14 Aug 2020 18:48:33 +0200 Subject: [PATCH] Fix number abbreviation when the number is n-thousand This commit fixes the method `abbreviateNumber` so that it behaves as stated in the JSDoc. Previously, an input of `1234` would have produced `1K`. With this change, the output will be `1.2K`. --- js/src/common/utils/abbreviateNumber.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/common/utils/abbreviateNumber.ts b/js/src/common/utils/abbreviateNumber.ts index 4a691be968..63651d7408 100644 --- a/js/src/common/utils/abbreviateNumber.ts +++ b/js/src/common/utils/abbreviateNumber.ts @@ -10,7 +10,7 @@ export default function abbreviateNumber(number: number): string { if (number >= 1000000) { return Math.floor(number / 1000000) + app.translator.trans('core.lib.number_suffix.mega_text'); } else if (number >= 1000) { - return Math.floor(number / 1000) + app.translator.trans('core.lib.number_suffix.kilo_text'); + return (number / 1000).toFixed(1) + app.translator.trans('core.lib.number_suffix.kilo_text'); } else { return number.toString(); }