dynamicDecimals

This commit is contained in:
Luis Fernando Molina committed 2020-03-16 14:35:13 +01:00
1 parent dbbd25559f
commit a1cfd82ab3
2 files changed
+10 -6

No files matched your search

+1 -6
View File
@@ -487,12 +487,7 @@ function newRateScale () {
rate = coordinateSystem.max.y
}
let decimals = 2
if (rate < 1) { decimals = 4 }
if (Math.trunc(rate * 100) < 1) { decimals = 6 }
if (Math.trunc(rate * 10000) < 1) { decimals = 8 }
if (Math.trunc(rate * 1000000) < 1) { decimals = 10 }
let label = (rate - Math.trunc(rate)).toFixed(decimals)
let label = dynamicDecimals(rate)
let labelArray = label.split('.')
let label1 = thisObject.payload.node.payload.parentNode.name
let label2 = (Math.trunc(rate)).toLocaleString()
+9
View File
@@ -22,6 +22,15 @@ function drawContainerBackground (container, color, opacity, fitFunction) {
browserCanvasContext.fill()
}
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 }
return (value - Math.trunc(value)).toFixed(decimals)
}
function savePropertyAtNodeConfig (payload, propertyName, value) {
try {
let code = JSON.parse(payload.node.code)