@cryptotaxi247 / netdata-1 / commits / d5915ece7

eliminated legend updates which the chart is panned

Costa Tsaousis (ktsaou) committed Oct 31, 2017 at 05:16 UTC d5915ece79160e28a456331ddc19b1ecb0641512
1 file changed +47 -15
web/dashboard.js
+47 -15
@@ -594,6 +594,8 @@ var NETDATA = window.NETDATA || {};
594 NETDATA.onscroll_updater_max_duration = 0;
595 NETDATA.onscroll_updater_above_threshold_count = 0;
596 NETDATA.onscroll_updater = function() {
597 + NETDATA.globalSelectionSync.stop();
598 +
599 NETDATA.onscroll_updater_running = true;
600 NETDATA.onscroll_updater_count++;
601 var start = Date.now();
@@ -1895,6 +1897,10 @@ var NETDATA = window.NETDATA || {};
1897 slaves: [],
1898 timeout_id: null,
1899
1900 + active: function() {
1901 + return (this.state !== null);
1902 + },
1903 +
1904 // return true if global selection sync can be enabled now
1905 enabled: function() {
1906 // console.log('enabled()');
@@ -1907,12 +1913,12 @@ var NETDATA = window.NETDATA || {};
1913
1914 // set the global selection sync master
1915 setMaster: function(state) {
1910 - // console.log('setMaster()');
1911 - if(NETDATA.options.current.sync_selection === false || this.state === state)
1916 + if(this.enabled() !== true || this.state === state)
1917 return;
1918
1914 - if(this.state !== null)
1915 - this.stop();
1919 + // console.log('setMaster()');
1920 +
1921 + this.stop();
1922
1923 state.selected = true;
1924 this.state = state;
@@ -1932,8 +1938,9 @@ var NETDATA = window.NETDATA || {};
1938
1939 // stop global selection sync
1940 stop: function() {
1935 - // console.log('stop()');
1941 if(this.state !== null) {
1942 + // console.log('stop()');
1943 +
1944 var len = this.slaves.length;
1945 while (len--)
1946 this.slaves[len].clearSelection();
@@ -1948,9 +1955,9 @@ var NETDATA = window.NETDATA || {};
1955
1956 // delay global selection sync for some time
1957 delay: function(ms) {
1951 - // console.log('delay()');
1952 -
1958 if(NETDATA.options.current.sync_selection === true) {
1959 + // console.log('delay()');
1960 +
1961 if(typeof ms === 'number')
1962 this.dont_sync_before = Date.now() + ms;
1963 else
@@ -1972,11 +1979,10 @@ var NETDATA = window.NETDATA || {};
1979 // sync all the visible charts to the given time
1980 // this is to be called from the chart libraries
1981 sync: function(state, t) {
1975 - // console.log('sync()');
1976 -
1982 if(NETDATA.options.current.sync_selection === true) {
1978 - if(this.state !== state)
1979 - this.setMaster(state);
1983 + // console.log('sync()');
1984 +
1985 + this.setMaster(state);
1986
1987 if(t === this.last_t)
1988 return;
@@ -2920,6 +2926,14 @@ var NETDATA = window.NETDATA || {};
2926
2927 this.updateChartPanOrZoomAsyncTimeOutId = null;
2928 this.updateChartPanOrZoomAsync = function(after, before, callback) {
2929 + if(NETDATA.globalPanAndZoom.isMaster(this) === false) {
2930 + this.pauseChart();
2931 + NETDATA.globalPanAndZoom.setMaster(this, after, before);
2932 + NETDATA.globalSelectionSync.stop();
2933 + NETDATA.globalSelectionSync.delay();
2934 + NETDATA.globalSelectionSync.setMaster(this);
2935 + }
2936 +
2937 if(this.updateChartPanOrZoomAsyncTimeOutId !== null)
2938 clearTimeout(this.updateChartPanOrZoomAsyncTimeOutId);
2939
@@ -4184,7 +4198,7 @@ var NETDATA = window.NETDATA || {};
4198 };
4199
4200 this.isAutoRefreshable = function() {
4187 - return (this.current.autorefresh);
4201 + return (this.current.autorefresh && NETDATA.globalSelectionSync.active() === false && NETDATA.globalPanAndZoom.isActive() === false);
4202 };
4203
4204 this.canBeAutoRefreshed = function() {
@@ -5301,6 +5315,9 @@ var NETDATA = window.NETDATA || {};
5315 }
5316 },
5317 legendFormatter: function(data) {
5318 + if(state.tmp.dygraph_mouse_down === true)
5319 + return;
5320 +
5321 var elements = state.element_legend_childs;
5322
5323 // if the hidden div is not there
@@ -5363,7 +5380,8 @@ var NETDATA = window.NETDATA || {};
5380 // var t = state.data_after + row * state.data_update_every;
5381 // console.log('row = ' + row + ', x = ' + x + ', t = ' + t + ' ' + ((t === x)?'SAME':(Math.abs(x-t)<=state.data_update_every)?'SIMILAR':'DIFFERENT') + ', rows in db: ' + state.data_points + ' visible(x) = ' + state.timeIsVisible(x) + ' visible(t) = ' + state.timeIsVisible(t) + ' r(x) = ' + state.calculateRowForTime(x) + ' r(t) = ' + state.calculateRowForTime(t) + ' range: ' + state.data_after + ' - ' + state.data_before + ' real: ' + state.data.after + ' - ' + state.data.before + ' every: ' + state.data_update_every);
5382
5366 - NETDATA.globalSelectionSync.sync(state, x);
5383 + if(state.tmp.dygraph_mouse_down !== true)
5384 + NETDATA.globalSelectionSync.sync(state, x);
5385
5386 // fix legend zIndex using the internal structures of dygraph legend module
5387 // this works, but it is a hack!
@@ -5372,6 +5390,9 @@ var NETDATA = window.NETDATA || {};
5390 unhighlightCallback: function(event) {
5391 void(event);
5392
5393 + if(state.tmp.dygraph_mouse_down === true)
5394 + return;
5395 +
5396 if(NETDATA.options.debug.dygraph === true || state.debug === true)
5397 state.log('dygraphUnhighlightCallback()');
5398
@@ -5392,6 +5413,7 @@ var NETDATA = window.NETDATA || {};
5413 // Right-click should not initiate a zoom.
5414 if(event.button && event.button === 2) return;
5415
5416 + state.tmp.dygraph_mouse_down = true;
5417 context.initializeMouseDown(event, dygraph, context);
5418
5419 if(event.button && event.button === 1) {
@@ -5440,6 +5462,8 @@ var NETDATA = window.NETDATA || {};
5462 }
5463 },
5464 mouseup: function(event, dygraph, context) {
5465 + state.tmp.dygraph_mouse_down = false;
5466 +
5467 if(NETDATA.options.debug.dygraph === true || state.debug === true)
5468 state.log('interactionModel.mouseup()');
5469
@@ -5588,6 +5612,8 @@ var NETDATA = window.NETDATA || {};
5612 }
5613 },
5614 touchstart: function(event, dygraph, context) {
5615 + state.tmp.dygraph_mouse_down = true;
5616 +
5617 if(NETDATA.options.debug.dygraph === true || state.debug === true)
5618 state.log('interactionModel.touchstart()');
5619
@@ -5619,6 +5645,8 @@ var NETDATA = window.NETDATA || {};
5645 state.dygraph_last_touch_move = Date.now();
5646 },
5647 touchend: function(event, dygraph, context) {
5648 + state.tmp.dygraph_mouse_down = false;
5649 +
5650 if(NETDATA.options.debug.dygraph === true || state.debug === true)
5651 state.log('interactionModel.touchend()');
5652
@@ -6364,7 +6392,9 @@ var NETDATA = window.NETDATA || {};
6392 if(typeof state.tmp.easyPieChartUnits !== 'undefined')
6393 state.tmp.easyPieChartUnits.innerText = units;
6394 };
6367 - state.legendShowUndefined = function() {};
6395 + state.legendShowUndefined = function() {
6396 + NETDATA.easypiechartClearSelection(state);
6397 + };
6398
6399 return true;
6400 };
@@ -6735,7 +6765,9 @@ var NETDATA = window.NETDATA || {};
6765 state.tmp.___gaugeOld__.maxLabel = null;
6766 }
6767 };
6738 - state.legendShowUndefined = function() {};
6768 + state.legendShowUndefined = function() {
6769 + NETDATA.gaugeClearSelection(state);
6770 + };
6771
6772 return true;
6773 };