@cryptotaxi247 / netdata-1 / commits / 2ea8f7a8f

more global pan and zoom fixes to allow rapid sync of charts on double click

Costa Tsaousis (ktsaou) committed Dec 8, 2015 at 03:23 UTC 2ea8f7a8fab84bd324f46d400b6c473cdda8bf5a
1 file changed +40 -21
web/dashboard.js
+40 -21
@@ -298,6 +298,8 @@
298
299 // clear the master
300 clearMaster: function() {
301 + if(!NETDATA.options.current.sync_pan_and_zoom) return;
302 +
303 if(this.master) {
304 var state = this.master;
305 this.master = null; // prevent infinite recursion
@@ -411,7 +413,7 @@
413 name: 'auto',
414 autorefresh: true,
415 url: 'invalid://', // string - the last url used to update the chart
414 - last_updated_ms: 0, // milliseconds - the timestamp of last refresh
416 + last_autorefreshed: 0, // milliseconds - the timestamp of last automatic refresh
417 view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
418 after_ms: 0, // milliseconds - the first timestamp of the data
419 before_ms: 0, // milliseconds - the last timestamp of the data
@@ -428,7 +430,7 @@
430 name: 'pan',
431 autorefresh: false,
432 url: 'invalid://', // string - the last url used to update the chart
431 - last_updated_ms: 0, // milliseconds - the timestamp of last refresh
433 + last_autorefreshed: 0, // milliseconds - the timestamp of last refresh
434 view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
435 after_ms: 0, // milliseconds - the first timestamp of the data
436 before_ms: 0, // milliseconds - the last timestamp of the data
@@ -445,7 +447,7 @@
447 name: 'zoom',
448 autorefresh: false,
449 url: 'invalid://', // string - the last url used to update the chart
448 - last_updated_ms: 0, // milliseconds - the timestamp of last refresh
450 + last_autorefreshed: 0, // milliseconds - the timestamp of last refresh
451 view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
452 after_ms: 0, // milliseconds - the first timestamp of the data
453 before_ms: 0, // milliseconds - the last timestamp of the data
@@ -467,6 +469,10 @@
469 console.log(this.id + ' (' + this.library_name + ' ' + this.uuid + '): ' + msg);
470 },
471
472 + delaySelectionSync: function() {
473 + NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
474 + },
475 +
476 setSelection: function(t) {
477 if(typeof this.library.setSelection == 'function') {
478 if(this.library.setSelection(this, t))
@@ -524,15 +530,19 @@
530 },
531
532 resetChart: function() {
527 - if(NETDATA.globalPanAndZoom.isMaster(this))
533 + if(NETDATA.globalPanAndZoom.isMaster(this)) {
534 NETDATA.globalPanAndZoom.clearMaster();
535 + // it will call us back - no need to do
536 + // anything more.
537 + return;
538 + }
539
530 - if(state.current.name != 'auto')
540 + //if(state.current.name != 'auto')
541 this.setMode('auto');
542
543 this.current.force_before_ms = null;
544 this.current.force_after_ms = null;
535 - this.current.last_updated_ms = 0;
545 + this.current.last_autorefreshed = 0;
546 this.follows_global = 0;
547 this.paused = false;
548 this.selected = false;
@@ -552,7 +562,7 @@
562 if(this.current.name == m) return;
563
564 this[m].url = this.current.url;
555 - this[m].last_updated_ms = this.current.last_updated_ms;
565 + this[m].last_autorefreshed = this.current.last_autorefreshed;
566 this[m].view_update_every = this.current.view_update_every;
567 this[m].after_ms = this.current.after_ms;
568 this[m].before_ms = this.current.before_ms;
@@ -805,6 +815,7 @@
815
816 // this may force the chart to be re-created
817 this.resizeChart();
818 +
819 if(this.updates_since_last_creation >= this.library.max_updates_to_recreate) {
820 if(this.debug) this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
821 this.created_ms = 0;
@@ -848,8 +859,16 @@
859 }
860
861 // update the performance counters
851 - this.current.last_updated_ms = new Date().getTime();
852 - this.refresh_dt_ms = this.current.last_updated_ms - started;
862 + var now = new Date().getTime();
863 +
864 + // don't update last_update_ms if this chart is
865 + // forced to be updated with global PanAndZoom
866 + if(NETDATA.globalPanAndZoom.isActive())
867 + this.current.last_autorefreshed = 0;
868 + else
869 + this.current.last_autorefreshed = now;
870 +
871 + this.refresh_dt_ms = now - started;
872 NETDATA.options.auto_refresher_fast_weight += this.refresh_dt_ms;
873
874 if(this.refresh_dt_element)
@@ -955,7 +974,7 @@
974 return false;
975 }
976
958 - if(now - this.current.last_updated_ms > this.current.view_update_every) {
977 + if(now - this.current.last_autorefreshed > this.current.view_update_every) {
978 if(this.debug) this.log('canBeAutoRefreshed(): It is time to update me.');
979 return true;
980 }
@@ -1777,7 +1796,7 @@
1796 zoomCallback: function(minDate, maxDate, yRanges) {
1797 if(NETDATA.options.debug.dygraph) state.log('dygraphZoomCallback()');
1798 NETDATA.dygraph.syncStop(state);
1780 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1799 + state.delaySelectionSync();
1800 NETDATA.dygraph.chartPanOrZoom(state, this, minDate, maxDate);
1801 },
1802 highlightCallback: function(event, x, points, row, seriesName) {
@@ -1805,24 +1824,24 @@
1824 if(event.button && event.button == 1) {
1825 if (event.altKey || event.shiftKey) {
1826 state.setMode('pan');
1808 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1827 + state.delaySelectionSync();
1828 Dygraph.startPan(event, dygraph, context);
1829 }
1830 else {
1831 state.setMode('zoom');
1813 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1832 + state.delaySelectionSync();
1833 Dygraph.startZoom(event, dygraph, context);
1834 }
1835 }
1836 else {
1837 if (event.altKey || event.shiftKey) {
1838 state.setMode('zoom');
1820 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1839 + state.delaySelectionSync();
1840 Dygraph.startZoom(event, dygraph, context);
1841 }
1842 else {
1843 state.setMode('pan');
1825 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1844 + state.delaySelectionSync();
1845 Dygraph.startPan(event, dygraph, context);
1846 }
1847 }
@@ -1832,13 +1851,13 @@
1851
1852 if(context.isPanning) {
1853 NETDATA.dygraph.syncStop(state);
1835 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1854 + state.delaySelectionSync();
1855 state.setMode('pan');
1856 Dygraph.movePan(event, dygraph, context);
1857 }
1858 else if(context.isZooming) {
1859 NETDATA.dygraph.syncStop(state);
1841 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1860 + state.delaySelectionSync();
1861 state.setMode('zoom');
1862 Dygraph.moveZoom(event, dygraph, context);
1863 }
@@ -1847,11 +1866,11 @@
1866 if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mouseup()');
1867
1868 if (context.isPanning) {
1850 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1869 + state.delaySelectionSync();
1870 Dygraph.endPan(event, dygraph, context);
1871 }
1872 else if (context.isZooming) {
1854 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1873 + state.delaySelectionSync();
1874 Dygraph.endZoom(event, dygraph, context);
1875 }
1876 },
@@ -1868,7 +1887,7 @@
1887 if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mousewheel()');
1888
1889 NETDATA.dygraph.syncStop(state);
1871 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1890 + state.delaySelectionSync();
1891
1892 if(event.altKey || event.shiftKey) {
1893 // http://dygraphs.com/gallery/interaction-api.js
@@ -1894,7 +1913,7 @@
1913 touchstart: function(event, dygraph, context) {
1914 if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.touchstart()');
1915 NETDATA.dygraph.syncStop(state);
1897 - NETDATA.dygraph.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
1916 + state.delaySelectionSync();
1917 Dygraph.Interaction.startTouch(event, dygraph, context);
1918 context.touchDirections = { x: true, y: false };
1919 state.setMode('zoom');