allow min/max of easypiechart and gauge be non-zero-based, when they have set by the user; fixes #2455
Costa Tsaousis (ktsaou) committed
Jul 15, 2017 at 13:20 UTC
497d6035b3afabe36afea2f52091f98f8bf35a1b
7 files changed
+22
-18
web/dashboard.html
+1
-1
@@ -652,4 +652,4 @@ So, to avoid flashing the charts, we destroy and re-create the charts on each up
652
<!-- <script> netdataServer = "http://box:19999"; </script> -->
653
654
<!-- load the dashboard manager - it will do the rest -->
655
-<script type="text/javascript" src="dashboard.js?v20170105-7"></script>
655
+<script type="text/javascript" src="dashboard.js?v20170715-1"></script>
web/dashboard.js
+16
-12
@@ -5552,7 +5552,7 @@ var NETDATA = window.NETDATA || {};
5552
5553
// ----------------------------------------------------------------------------------------------------------------
5554
5555
- NETDATA.easypiechartPercentFromValueMinMax = function(value, min, max) {
5555
+ NETDATA.easypiechartPercentFromValueMinMax = function(state, value, min, max) {
5556
if(typeof value !== 'number') value = 0;
5557
if(typeof min !== 'number') min = 0;
5558
if(typeof max !== 'number') max = 0;
@@ -5561,8 +5561,9 @@ var NETDATA = window.NETDATA || {};
5561
if(max < value) max = value;
5562
5563
// make sure it is zero based
5564
- if(min > 0) min = 0;
5565
- if(max < 0) max = 0;
5564
+ // but only they have not been set by the user
5565
+ if(state.tmp.easyPieChartMin === null && min > 0) min = 0;
5566
+ if(state.tmp.easyPieChartMax === null && max < 0) max = 0;
5567
5568
var pcent = 0;
5569
if(value >= 0) {
@@ -5649,7 +5650,7 @@ var NETDATA = window.NETDATA || {};
5650
var value = state.data.result[state.data.result.length - 1 - slot];
5651
var min = (state.tmp.easyPieChartMin === null)?NETDATA.commonMin.get(state):state.tmp.easyPieChartMin;
5652
var max = (state.tmp.easyPieChartMax === null)?NETDATA.commonMax.get(state):state.tmp.easyPieChartMax;
5652
- var pcent = NETDATA.easypiechartPercentFromValueMinMax(value, min, max);
5653
+ var pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max);
5654
5655
state.tmp.easyPieChartEvent.value = value;
5656
state.tmp.easyPieChartEvent.pcent = pcent;
@@ -5678,7 +5679,7 @@ var NETDATA = window.NETDATA || {};
5679
value = data.result[0];
5680
min = (state.tmp.easyPieChartMin === null)?NETDATA.commonMin.get(state):state.tmp.easyPieChartMin;
5681
max = (state.tmp.easyPieChartMax === null)?NETDATA.commonMax.get(state):state.tmp.easyPieChartMax;
5681
- pcent = NETDATA.easypiechartPercentFromValueMinMax(value, min, max);
5682
+ pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max);
5683
}
5684
5685
state.tmp.easyPieChartLabel.innerText = state.legendFormatValue(value);
@@ -5707,7 +5708,7 @@ var NETDATA = window.NETDATA || {};
5708
else
5709
state.tmp.easyPieChartMax = max;
5710
5710
- var pcent = NETDATA.easypiechartPercentFromValueMinMax(value, min, max);
5711
+ var pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max);
5712
5713
chart.data('data-percent', pcent);
5714
@@ -5919,8 +5920,9 @@ var NETDATA = window.NETDATA || {};
5920
var max = (state.tmp.gaugeMax === null)?NETDATA.commonMax.get(state):state.tmp.gaugeMax;
5921
5922
// make sure it is zero based
5922
- if(min > 0) min = 0;
5923
- if(max < 0) max = 0;
5923
+ // but only if it has not been set by the user
5924
+ if(state.tmp.gaugeMin === null && min > 0) min = 0;
5925
+ if(state.tmp.gaugeMax === null && max < 0) max = 0;
5926
5927
state.tmp.gaugeEvent.value = value;
5928
state.tmp.gaugeEvent.min = min;
@@ -5956,8 +5958,9 @@ var NETDATA = window.NETDATA || {};
5958
if(value > max) max = value;
5959
5960
// make sure it is zero based
5959
- if(min > 0) min = 0;
5960
- if(max < 0) max = 0;
5961
+ // but only if it has not been set by the user
5962
+ if(state.tmp.gaugeMin === null && min > 0) min = 0;
5963
+ if(state.tmp.gaugeMax === null && max < 0) max = 0;
5964
5965
NETDATA.gaugeSetLabels(state, value, min, max);
5966
}
@@ -5994,8 +5997,9 @@ var NETDATA = window.NETDATA || {};
5997
state.tmp.gaugeMax = max;
5998
5999
// make sure it is zero based
5997
- if(min > 0) min = 0;
5998
- if(max < 0) max = 0;
6000
+ // but only if it has not been set by the user
6001
+ if(state.tmp.gaugeMin === null && min > 0) min = 0;
6002
+ if(state.tmp.gaugeMax === null && max < 0) max = 0;
6003
6004
var width = state.chartWidth(), height = state.chartHeight(); //, ratio = 1.5;
6005
// console.log('gauge width: ' + width.toString() + ', height: ' + height.toString());
web/demo.html
+1
-1
@@ -20,7 +20,7 @@
20
<meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
21
<meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
22
</head>
23
-<script type="text/javascript" src="dashboard.js?v20170105-7"></script>
23
+<script type="text/javascript" src="dashboard.js?v20170715-1"></script>
24
<body>
25
26
<div style="width: 100%; text-align: center;">
web/demo2.html
+1
-1
@@ -21,7 +21,7 @@
21
<meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
22
</head>
23
<script>var netdataTheme = 'slate';</script>
24
-<script type="text/javascript" src="http://my-netdata.io/dashboard.js?v20170105-7"></script>
24
+<script type="text/javascript" src="http://my-netdata.io/dashboard.js?v20170715-1"></script>
25
<body>
26
27
<div class="container" style="width: 90%; padding-top: 10px; text-align: center; color: #AAA">
web/demosites.html
+1
-1
@@ -516,7 +516,7 @@ p {
516
and that you have chown it to be owned by netdata:netdata
517
-->
518
<!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
519
-<script type="text/javascript" src="dashboard.js?v20170105-7"></script>
519
+<script type="text/javascript" src="dashboard.js?v20170715-1"></script>
520
521
<script>
522
// --- OPTIONS FOR THE CHARTS --
web/demosites2.html
+1
-1
@@ -52,7 +52,7 @@
52
and that you have chown it to be owned by netdata:netdata
53
-->
54
<!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
55
- <script type="text/javascript" src="dashboard.js?v20170105-7"></script>
55
+ <script type="text/javascript" src="dashboard.js?v20170715-1"></script>
56
57
<script>
58
// --- OPTIONS FOR THE CHARTS --
web/index.html
+1
-1
@@ -3589,4 +3589,4 @@
3589
</div>
3590
</body>
3591
</html>
3592
-<script type="text/javascript" src="dashboard.js?v20170605-2"></script>
3592
+<script type="text/javascript" src="dashboard.js?v20170715-1"></script>