From: Costa Tsaousis (ktsaou) Date: Sun, 5 Feb 2017 22:12:08 +0000 (+0200) Subject: respect custom dashboards decimal digits settings X-Git-Tag: ab-debian_0.20170213.01-0ab1~1^2~24^2~1 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netdata.git;a=commitdiff_plain;h=9706ec1c42c19da932fbd4bcdc38105c13dd3792 respect custom dashboards decimal digits settings --- diff --git a/web/dashboard.js b/web/dashboard.js index ed783bf0..a462f10f 100644 --- a/web/dashboard.js +++ b/web/dashboard.js @@ -1363,9 +1363,7 @@ var NETDATA = window.NETDATA || {}; this.value_decimal_detail = -1; var d = self.data('decimal-digits'); if(typeof d === 'number') { - this.value_decimal_detail = 1; - while(d-- > 0) - this.value_decimal_detail *= 10; + this.value_decimal_detail = d; } this.auto = { @@ -2254,21 +2252,26 @@ var NETDATA = window.NETDATA || {}; if(min === __legendFormatValueChartDecimalsLastMin && max === __legendFormatValueChartDecimalsLastMax) return; - __legendFormatValueChartDecimalsLastMin = min; - __legendFormatValueChartDecimalsLastMax = max; + if(this.value_decimal_detail !== -1) { + __legendFormatValueChartDecimals = this.value_decimal_detail; + } + else { + __legendFormatValueChartDecimalsLastMin = min; + __legendFormatValueChartDecimalsLastMax = max; - var delta; + var delta; - if(min === max) - delta = Math.abs(min); - else - delta = Math.abs(max - min); + if (min === max) + delta = Math.abs(min); + else + delta = Math.abs(max - min); - if(delta > 1000) __legendFormatValueChartDecimals = 0; - else if(delta > 10 ) __legendFormatValueChartDecimals = 1; - else if(delta > 1 ) __legendFormatValueChartDecimals = 2; - else if(delta > 0.1 ) __legendFormatValueChartDecimals = 3; - else __legendFormatValueChartDecimals = 4; + if (delta > 1000) __legendFormatValueChartDecimals = 0; + else if (delta > 10) __legendFormatValueChartDecimals = 1; + else if (delta > 1) __legendFormatValueChartDecimals = 2; + else if (delta > 0.1) __legendFormatValueChartDecimals = 3; + else __legendFormatValueChartDecimals = 4; + } }; this.legendFormatValue = function(value) { @@ -2276,10 +2279,6 @@ var NETDATA = window.NETDATA || {}; var dmin, dmax; - if(this.value_decimal_detail !== -1) { - dmin = dmax = this.value_decimal_detail; - } - if(__legendFormatValueChartDecimals < 0) { dmin = 0; var abs = value; @@ -2293,6 +2292,10 @@ var NETDATA = window.NETDATA || {}; dmin = dmax = __legendFormatValueChartDecimals; } + if(this.value_decimal_detail !== -1) { + dmin = dmax = this.value_decimal_detail; + } + return value.toLocaleString(undefined, { // style: 'decimal', // minimumIntegerDigits: 1, diff --git a/web/index.html b/web/index.html index 2edfbe72..04ff2218 100644 --- a/web/index.html +++ b/web/index.html @@ -3312,4 +3312,4 @@ - +