X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=extras%2Fsynchronizer.js;h=16e4d96bc36926a8a0a502bc7d20c294c705a3a5;hb=ef44ba44d235f6e6fbbc3ae481661380cb6514be;hp=ebc9a45709b356ef7e0135cc4cc51d686876a58d;hpb=fcf37b294f0f83b799c756017cab8ee0ceeb9a3e;p=dygraphs.git diff --git a/extras/synchronizer.js b/extras/synchronizer.js index ebc9a45..16e4d96 100644 --- a/extras/synchronizer.js +++ b/extras/synchronizer.js @@ -100,16 +100,24 @@ Dygraph.synchronize = function(/* dygraphs..., opts */) { throw 'Invalid invocation of Dygraph.synchronize(). ' + 'Need two or more dygraphs to synchronize.'; } + + var readycount = dygraphs.length; + for (var i = 0; i < dygraphs.length; i++) { + var g = dygraphs[i]; + g.ready( function() { + if (--readycount == 0) { + // Listen for draw, highlight, unhighlight callbacks. + if (opts.zoom) { + attachZoomHandlers(dygraphs, opts, prevCallbacks); + } - // Listen for draw, highlight, unhighlight callbacks. - if (opts.zoom) { - attachZoomHandlers(dygraphs, opts, prevCallbacks); - } - - if (opts.selection) { - attachSelectionHandlers(dygraphs, prevCallbacks); + if (opts.selection) { + attachSelectionHandlers(dygraphs, prevCallbacks); + } + } + }); } - + return { detach: function() { for (var i = 0; i < dygraphs.length; i++) {