From 6dc561b8f6a81f4e90dd49f25882bb4661f122cd Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 14 Feb 2021 23:59:23 +0100 Subject: [PATCH] fix numberToString --- src/core/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/utils.js b/src/core/utils.js index 57a9364..a7faf99 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -195,7 +195,7 @@ export function numberToString(num: number): string { while (postfixNum < postfix.length) { if (num < 10000) { // eslint-disable-next-line max-len - return `${Math.floor(num / 1000)}.${Math.floor((num % 1000) / 10)}${postfix[postfixNum]}`; + return `${Math.floor(num / 1000)}.${(`0${Math.floor((num % 1000) / 10)}`).slice(-2)}${postfix[postfixNum]}`; } if (num < 100000) { // eslint-disable-next-line max-len return `${Math.floor(num / 1000)}.${Math.floor((num % 1000) / 100)}${postfix[postfixNum]}`; @@ -208,9 +208,6 @@ export function numberToString(num: number): string { return ''; } -/* - * generates a color based on a given string - */ export function numberToStringFull(num: number): string { if (num < 0) { return `${num} :-(`; @@ -224,6 +221,9 @@ export function numberToStringFull(num: number): string { return `${Math.floor(num / 1000000)}.${(`00${String(Math.floor(num / 1000))}`).slice(-3)}.${(`00${String(num % 1000)}`).slice(-3)}`; } +/* + * generates a color based on a given string + */ export function colorFromText(str: string) { if (!str) return '#000000';