From: Justin Standring Date: Fri, 8 Jul 2016 23:05:40 +0000 (-0700) Subject: Check for new options before updating synchronised graphs (Fixes #760) X-Git-Tag: v2.0.0~24^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=b55a71d768d2f8de62877c32b3aec9e9975ac389;p=dygraphs.git Check for new options before updating synchronised graphs (Fixes #760) --- diff --git a/src/extras/synchronizer.js b/src/extras/synchronizer.js old mode 100644 new mode 100755 index bf5b6f3..6f369f3 --- a/src/extras/synchronizer.js +++ b/src/extras/synchronizer.js @@ -153,6 +153,16 @@ var synchronize = function(/* dygraphs..., opts */) { }; }; +function arraysAreEqual(a, b) { + if (!Array.isArray(a) || !Array.isArray(b)) return false; + var i = a.length; + if (i !== b.length) return false; + while (i--) { + if (a[i] !== b[i]) return false; + } + return true; +} + function attachZoomHandlers(gs, syncOpts, prevCallbacks) { var block = false; for (var i = 0; i < gs.length; i++) { @@ -173,6 +183,13 @@ function attachZoomHandlers(gs, syncOpts, prevCallbacks) { } continue; } + + // Only redraw if there are new options + if (arraysAreEqual(opts.dateWindow, gs[j].getOption('dateWindow')) && + arraysAreEqual(opts.valueRange, gs[j].getOption('valueRange'))) { + continue; + } + gs[j].updateOptions(opts); } block = false;