respect custom dashboards decimal digits settings
Costa Tsaousis (ktsaou) committed
Feb 6, 2017 at 00:12 UTC
9706ec1c42c19da932fbd4bcdc38105c13dd3792
2 files changed
+23
-20
web/dashboard.js
+22
-19
@@ -1363,9 +1363,7 @@ var NETDATA = window.NETDATA || {};
1363
this.value_decimal_detail = -1;
1364
var d = self.data('decimal-digits');
1365
if(typeof d === 'number') {
1366
- this.value_decimal_detail = 1;
1367
- while(d-- > 0)
1368
- this.value_decimal_detail *= 10;
1366
+ this.value_decimal_detail = d;
1367
}
1368
1369
this.auto = {
@@ -2254,21 +2252,26 @@ var NETDATA = window.NETDATA || {};
2252
if(min === __legendFormatValueChartDecimalsLastMin && max === __legendFormatValueChartDecimalsLastMax)
2253
return;
2254
2257
- __legendFormatValueChartDecimalsLastMin = min;
2258
- __legendFormatValueChartDecimalsLastMax = max;
2255
+ if(this.value_decimal_detail !== -1) {
2256
+ __legendFormatValueChartDecimals = this.value_decimal_detail;
2257
+ }
2258
+ else {
2259
+ __legendFormatValueChartDecimalsLastMin = min;
2260
+ __legendFormatValueChartDecimalsLastMax = max;
2261
2260
- var delta;
2262
+ var delta;
2263
2262
- if(min === max)
2263
- delta = Math.abs(min);
2264
- else
2265
- delta = Math.abs(max - min);
2264
+ if (min === max)
2265
+ delta = Math.abs(min);
2266
+ else
2267
+ delta = Math.abs(max - min);
2268
2267
- if(delta > 1000) __legendFormatValueChartDecimals = 0;
2268
- else if(delta > 10 ) __legendFormatValueChartDecimals = 1;
2269
- else if(delta > 1 ) __legendFormatValueChartDecimals = 2;
2270
- else if(delta > 0.1 ) __legendFormatValueChartDecimals = 3;
2271
- else __legendFormatValueChartDecimals = 4;
2269
+ if (delta > 1000) __legendFormatValueChartDecimals = 0;
2270
+ else if (delta > 10) __legendFormatValueChartDecimals = 1;
2271
+ else if (delta > 1) __legendFormatValueChartDecimals = 2;
2272
+ else if (delta > 0.1) __legendFormatValueChartDecimals = 3;
2273
+ else __legendFormatValueChartDecimals = 4;
2274
+ }
2275
};
2276
2277
this.legendFormatValue = function(value) {
@@ -2276,10 +2279,6 @@ var NETDATA = window.NETDATA || {};
2279
2280
var dmin, dmax;
2281
2279
- if(this.value_decimal_detail !== -1) {
2280
- dmin = dmax = this.value_decimal_detail;
2281
- }
2282
-
2282
if(__legendFormatValueChartDecimals < 0) {
2283
dmin = 0;
2284
var abs = value;
@@ -2293,6 +2292,10 @@ var NETDATA = window.NETDATA || {};
2292
dmin = dmax = __legendFormatValueChartDecimals;
2293
}
2294
2295
+ if(this.value_decimal_detail !== -1) {
2296
+ dmin = dmax = this.value_decimal_detail;
2297
+ }
2298
+
2299
return value.toLocaleString(undefined, {
2300
// style: 'decimal',
2301
// minimumIntegerDigits: 1,
web/index.html
+1
-1
@@ -3312,4 +3312,4 @@
3312
</div>
3313
</body>
3314
</html>
3315
-<script type="text/javascript" src="dashboard.js?v20170205-37"></script>
3315
+<script type="text/javascript" src="dashboard.js?v20170205-39"></script>