@cryptotaxi247 / netdata-1 / commits / 409f88ca2

reset gauges when starting pan or zoom operations

Costa Tsaousis (ktsaou) committed Nov 1, 2017 at 01:18 UTC 409f88ca2dc7771ef6d71dc2e072cc9362b3b13c
1 file changed +65 -26
web/dashboard.js
+65 -26
@@ -392,7 +392,9 @@ var NETDATA = window.NETDATA || {};
392 chart_timing: false,
393 chart_calls: false,
394 libraries: false,
395 - dygraph: false
395 + dygraph: false,
396 + globalSelectionSync:false,
397 + globalPanAndZoom: false
398 }
399 };
400
@@ -1215,20 +1217,36 @@ var NETDATA = window.NETDATA || {};
1217
1218 callback: null,
1219
1220 + delay: function() {
1221 + if(NETDATA.options.debug.globalPanAndZoom === true)
1222 + console.log('globalPanAndZoom.delay()');
1223 +
1224 + NETDATA.options.auto_refresher_stop_until = Date.now() + NETDATA.options.current.global_pan_sync_time;
1225 + },
1226 +
1227 // set a new master
1228 setMaster: function(state, after, before) {
1229 + this.delay();
1230 +
1231 if(NETDATA.options.current.sync_pan_and_zoom === false)
1232 return;
1233
1223 - if(this.master !== null && this.master !== state)
1234 + if(this.master === null) {
1235 + if(NETDATA.options.debug.globalPanAndZoom === true)
1236 + console.log('globalPanAndZoom.setMaster(' + state.id + ', ' + after + ', ' + before + ') SET MASTER');
1237 + }
1238 + else if(this.master !== state) {
1239 + if(NETDATA.options.debug.globalPanAndZoom === true)
1240 + console.log('globalPanAndZoom.setMaster(' + state.id + ', ' + after + ', ' + before + ') CHANGED MASTER');
1241 +
1242 this.master.resetChart(true, true);
1243 + }
1244
1245 var now = Date.now();
1246 this.master = state;
1247 this.seq = now;
1248 this.force_after_ms = after;
1249 this.force_before_ms = before;
1231 - NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.global_pan_sync_time;
1250
1251 if(typeof this.callback === 'function')
1252 this.callback(true, after, before);
@@ -1236,6 +1254,9 @@ var NETDATA = window.NETDATA || {};
1254
1255 // clear the master
1256 clearMaster: function() {
1257 + if(NETDATA.options.debug.globalPanAndZoom === true)
1258 + console.log('globalPanAndZoom.clearMaster()');
1259 +
1260 if(this.master !== null) {
1261 var st = this.master;
1262 this.master = null;
@@ -1913,12 +1934,19 @@ var NETDATA = window.NETDATA || {};
1934
1935 // set the global selection sync master
1936 setMaster: function(state) {
1916 - if(this.enabled() !== true || this.state === state)
1937 + if(this.enabled() === false) {
1938 + this.stop();
1939 + return;
1940 + }
1941 +
1942 + if(this.state === state)
1943 return;
1944
1919 - // console.log('setMaster()');
1945 + if(this.state !== null)
1946 + this.stop();
1947
1921 - this.stop();
1948 + if(NETDATA.options.debug.globalSelectionSync === true)
1949 + console.log('globalSelectionSync.setMaster(' + state.id + ')');
1950
1951 state.selected = true;
1952 this.state = state;
@@ -1939,7 +1967,8 @@ var NETDATA = window.NETDATA || {};
1967 // stop global selection sync
1968 stop: function() {
1969 if(this.state !== null) {
1942 - // console.log('stop()');
1970 + if(NETDATA.options.debug.globalSelectionSync === true)
1971 + console.log('globalSelectionSync.stop()');
1972
1973 var len = this.slaves.length;
1974 while (len--)
@@ -1956,7 +1985,8 @@ var NETDATA = window.NETDATA || {};
1985 // delay global selection sync for some time
1986 delay: function(ms) {
1987 if(NETDATA.options.current.sync_selection === true) {
1959 - // console.log('delay()');
1988 + if(NETDATA.options.debug.globalSelectionSync === true)
1989 + console.log('globalSelectionSync.delay()');
1990
1991 if(typeof ms === 'number')
1992 this.dont_sync_before = Date.now() + ms;
@@ -1967,6 +1997,9 @@ var NETDATA = window.NETDATA || {};
1997
1998 __syncSlaves: function() {
1999 if(NETDATA.globalSelectionSync.enabled() === true) {
2000 + if(NETDATA.options.debug.globalSelectionSync === true)
2001 + console.log('globalSelectionSync.__syncSlaves()');
2002 +
2003 var t = NETDATA.globalSelectionSync.last_t;
2004 var len = NETDATA.globalSelectionSync.slaves.length;
2005 while (len--)
@@ -1980,7 +2013,8 @@ var NETDATA = window.NETDATA || {};
2013 // this is to be called from the chart libraries
2014 sync: function(state, t) {
2015 if(NETDATA.options.current.sync_selection === true) {
1983 - // console.log('sync()');
2016 + if(NETDATA.options.debug.globalSelectionSync === true)
2017 + console.log('globalSelectionSync.sync(' + state.id + ', ' + t.toString() + ')');
2018
2019 this.setMaster(state);
2020
@@ -2926,11 +2960,13 @@ var NETDATA = window.NETDATA || {};
2960
2961 this.updateChartPanOrZoomAsyncTimeOutId = null;
2962 this.updateChartPanOrZoomAsync = function(after, before, callback) {
2963 + NETDATA.globalPanAndZoom.delay();
2964 + NETDATA.globalSelectionSync.delay();
2965 +
2966 if(NETDATA.globalPanAndZoom.isMaster(this) === false) {
2967 this.pauseChart();
2968 NETDATA.globalPanAndZoom.setMaster(this, after, before);
2932 - NETDATA.globalSelectionSync.stop();
2933 - NETDATA.globalSelectionSync.delay();
2969 + // NETDATA.globalSelectionSync.stop();
2970 NETDATA.globalSelectionSync.setMaster(this);
2971 }
2972
@@ -5034,9 +5070,8 @@ var NETDATA = window.NETDATA || {};
5070 NETDATA.globalSelectionSync.delay();
5071 state.tmp.dygraph_user_action = true;
5072 state.tmp.dygraph_force_zoom = true;
5037 - state.updateChartPanOrZoomAsync(after, before, function() {
5038 - NETDATA.globalPanAndZoom.setMaster(state, after, before);
5039 - });
5073 + state.updateChartPanOrZoom(after, before);
5074 + NETDATA.globalPanAndZoom.setMaster(state, after, before);
5075 };
5076
5077 NETDATA.dygraphSetSelection = function(state, t) {
@@ -5405,7 +5440,9 @@ var NETDATA = window.NETDATA || {};
5440 state.log('interactionModel.mousedown()');
5441
5442 state.tmp.dygraph_user_action = true;
5408 - NETDATA.globalSelectionSync.stop();
5443 +
5444 + if(state.current && state.current.name !== 'auto')
5445 + NETDATA.globalSelectionSync.stop();
5446
5447 if(NETDATA.options.debug.dygraph === true)
5448 state.log('dygraphMouseDown()');
@@ -5419,24 +5456,24 @@ var NETDATA = window.NETDATA || {};
5456 if(event.button && event.button === 1) {
5457 if (event.altKey || event.shiftKey) {
5458 state.setMode('pan');
5422 - NETDATA.globalSelectionSync.delay();
5459 + // NETDATA.globalSelectionSync.delay();
5460 Dygraph.startPan(event, dygraph, context);
5461 }
5462 else {
5463 state.setMode('zoom');
5427 - NETDATA.globalSelectionSync.delay();
5464 + // NETDATA.globalSelectionSync.delay();
5465 Dygraph.startZoom(event, dygraph, context);
5466 }
5467 }
5468 else {
5469 if (event.altKey || event.shiftKey) {
5470 state.setMode('zoom');
5434 - NETDATA.globalSelectionSync.delay();
5471 + // NETDATA.globalSelectionSync.delay();
5472 Dygraph.startZoom(event, dygraph, context);
5473 }
5474 else {
5475 state.setMode('pan');
5439 - NETDATA.globalSelectionSync.delay();
5476 + // NETDATA.globalSelectionSync.delay();
5477 Dygraph.startPan(event, dygraph, context);
5478 }
5479 }
@@ -5447,16 +5484,16 @@ var NETDATA = window.NETDATA || {};
5484
5485 if(context.isPanning) {
5486 state.tmp.dygraph_user_action = true;
5450 - NETDATA.globalSelectionSync.stop();
5451 - NETDATA.globalSelectionSync.delay();
5487 + //NETDATA.globalSelectionSync.stop();
5488 + //NETDATA.globalSelectionSync.delay();
5489 state.setMode('pan');
5490 context.is2DPan = false;
5491 Dygraph.movePan(event, dygraph, context);
5492 }
5493 else if(context.isZooming) {
5494 state.tmp.dygraph_user_action = true;
5458 - NETDATA.globalSelectionSync.stop();
5459 - NETDATA.globalSelectionSync.delay();
5495 + //NETDATA.globalSelectionSync.stop();
5496 + //NETDATA.globalSelectionSync.delay();
5497 state.setMode('zoom');
5498 Dygraph.moveZoom(event, dygraph, context);
5499 }
@@ -5469,12 +5506,12 @@ var NETDATA = window.NETDATA || {};
5506
5507 if (context.isPanning) {
5508 state.tmp.dygraph_user_action = true;
5472 - NETDATA.globalSelectionSync.delay();
5509 + //NETDATA.globalSelectionSync.delay();
5510 Dygraph.endPan(event, dygraph, context);
5511 }
5512 else if (context.isZooming) {
5513 state.tmp.dygraph_user_action = true;
5477 - NETDATA.globalSelectionSync.delay();
5514 + //NETDATA.globalSelectionSync.delay();
5515 Dygraph.endZoom(event, dygraph, context);
5516 }
5517 },
@@ -5564,7 +5601,9 @@ var NETDATA = window.NETDATA || {};
5601 if(event.altKey || event.shiftKey) {
5602 state.tmp.dygraph_user_action = true;
5603
5567 - NETDATA.globalSelectionSync.stop();
5604 + if(state.current && state.current.name !== 'auto')
5605 + NETDATA.globalSelectionSync.stop();
5606 +
5607 NETDATA.globalSelectionSync.delay();
5608
5609 // http://dygraphs.com/gallery/interaction-api.js