fixed units scaling discrepancies
Costa Tsaousis (ktsaou) committed
Nov 16, 2017 at 23:02 UTC
5e5a1d0841086396d1e721ebe4b1b44b73bc4a63
2 files changed
+39
-6
web/dashboard.js
+27
-3
@@ -45,6 +45,8 @@
45
* (default: null) */
46
/*global netdataServer *//* string, the URL of the netdata server to use
47
* (default: the URL the page is hosted at) */
48
+/*global netdataSnapshotData *//* object, a netdata snapshot loaded
49
+ * (default: null) */
50
51
// ----------------------------------------------------------------------------
52
// global namespace
@@ -5324,7 +5326,7 @@ var NETDATA = window.NETDATA || {};
5326
};
5327
5328
if(!NETDATA.chartLibraries.dygraph.isSparkline(state)) {
5327
- options.ylabel = (state.dimensions_visibility.unselected_count !== 0)?"":state.units_current;
5329
+ options.ylabel = state.units_current; // (state.units_desired === 'auto')?"":state.units_current;
5330
}
5331
5332
if(state.tmp.dygraph_force_zoom === true) {
@@ -5433,7 +5435,7 @@ var NETDATA = window.NETDATA || {};
5435
xRangePad: NETDATA.dataAttribute(state.element, 'dygraph-xrangepad', 0),
5436
yRangePad: NETDATA.dataAttribute(state.element, 'dygraph-yrangepad', 1),
5437
valueRange: NETDATA.dataAttribute(state.element, 'dygraph-valuerange', [ null, null ]),
5436
- ylabel: state.units_current,
5438
+ ylabel: state.units_current, // (state.units_desired === 'auto')?"":state.units_current,
5439
yLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-ylabelwidth', 12),
5440
5441
// the function to plot the chart
@@ -5508,7 +5510,29 @@ var NETDATA = window.NETDATA || {};
5510
this.axes_[0].extremeRange[1]
5511
);
5512
5511
- return state.legendFormatValue(y);
5513
+ var old_units = this.user_attrs_.ylabel;
5514
+ var v = state.legendFormatValue(y);
5515
+ var new_units = state.units_current;
5516
+
5517
+ if(new_units !== old_units) {
5518
+ // console.log(this);
5519
+ // state.log('units discrepancy: old = ' + old_units + ', new = ' + new_units);
5520
+ var len = this.plugins_.length;
5521
+ while(len--) {
5522
+ // console.log(this.plugins_[len]);
5523
+ if(typeof this.plugins_[len].plugin.ylabel_div_ !== 'undefined') {
5524
+ this.plugins_[len].plugin.ylabel_div_.children[0].children[0].innerHTML = new_units;
5525
+ this.user_attrs_.ylabel = new_units;
5526
+ break;
5527
+ }
5528
+ }
5529
+
5530
+ if(len < 0)
5531
+ state.log('units discrepancy, but cannot find dygraphs div to change: old = ' + old_units + ', new = ' + new_units);
5532
+
5533
+ }
5534
+
5535
+ return v;
5536
}
5537
}
5538
},
web/index.html
+12
-3
@@ -3657,6 +3657,15 @@
3657
if(self.prop('checked') !== (NETDATA.getOption('units') === 'auto')) {
3658
self.bootstrapToggle(NETDATA.getOption('units') === 'auto' ? 'on' : 'off');
3659
}
3660
+
3661
+ if(self.prop('checked') === true) {
3662
+ $('#settingsLocaleTempRow').show();
3663
+ $('#settingsLocaleTimeRow').show();
3664
+ }
3665
+ else {
3666
+ $('#settingsLocaleTempRow').hide();
3667
+ $('#settingsLocaleTimeRow').hide();
3668
+ }
3669
};
3670
var temp_sync_option = function(option) {
3671
var self = $('#' + option);
@@ -4634,14 +4643,14 @@
4643
</small>
4644
</td>
4645
</tr>
4637
- <tr class="option-row">
4646
+ <tr id="settingsLocaleTempRow" class="option-row">
4647
<td class="option-control"><input id="units_temp" type="checkbox" checked data-toggle="toggle" data-on="Celsius" data-off="Fahrenheit" data-width="110px"></td>
4648
<td class="option-info"><strong>Which units to use for temperatures?</strong><br/>
4649
<small>Set the temperature units of the dashboard.
4650
</small>
4651
</td>
4652
</tr>
4644
- <tr class="option-row">
4653
+ <tr id="settingsLocaleTimeRow" class="option-row">
4654
<td class="option-control"><input id="seconds_as_time" type="checkbox" checked data-toggle="toggle" data-on="Time" data-off="Seconds" data-onstyle="success" data-width="110px"></td>
4655
<td class="option-info"><strong>Convert seconds to time?</strong><br/>
4656
<small>When set to <b>Time</b>, charts that present <code>seconds</code> will show <code>DDd:HH:MM:SS</code>.
@@ -5156,6 +5165,6 @@
5165
</div>
5166
</div>
5167
<div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5159
- <script type="text/javascript" src="dashboard.js?v20171115-1"></script>
5168
+ <script type="text/javascript" src="dashboard.js?v20171116-2"></script>
5169
</body>
5170
</html>