]> arthur.barton.de Git - netdata.git/commitdiff
respect custom dashboards decimal digits settings
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 5 Feb 2017 22:12:08 +0000 (00:12 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 5 Feb 2017 22:12:08 +0000 (00:12 +0200)
web/dashboard.js
web/index.html

index ed783bf07072aa7950bdebcf4f5df0ec20d1d332..a462f10faf63be6486cbac07b569090e9c6dc211 100644 (file)
@@ -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,
index 2edfbe72e83cc811a64cf5c5a052d9a654faa986..04ff2218b7f63c635ab426f9acaa5650ea2aea4c 100644 (file)
     </div>
 </body>
 </html>
-<script type="text/javascript" src="dashboard.js?v20170205-37"></script>
+<script type="text/javascript" src="dashboard.js?v20170205-39"></script>