From c38ecae794923d3f0b47144c23e7d11db0cfcf83 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 17 Mar 2020 15:56:53 +0100 Subject: [PATCH] bug fixed --- Utilities.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Utilities.js b/Utilities.js index fae5f22a5..7878498c3 100644 --- a/Utilities.js +++ b/Utilities.js @@ -25,11 +25,12 @@ function drawContainerBackground (container, color, opacity, fitFunction) { function dynamicDecimals (value) { let decimals = 2 if (value < 1) { decimals = 4 } - if (Math.trunc(value * 100) < 1) { decimals = 6 } - if (Math.trunc(value * 10000) < 1) { decimals = 8 } - if (Math.trunc(value * 1000000) < 1) { decimals = 10 } - if (Math.trunc(value * 100000000) < 1) { decimals = 12 } - if (Math.trunc(value * 10000000000) < 1) { decimals = 0 } + if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 6 } + if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 8 } + if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 10 } + if (Math.abs(Math.trunc(value * 100000000)) < 1) { decimals = 12 } + if (Math.abs(Math.trunc(value * 10000000000)) < 1) { value = 0; decimals = 0 } + if (Math.trunc(value) === value) { decimals = 0 } let returnValue = Number(value).toFixed(decimals) return returnValue }