Merge pull request #746 from mrcslws/wrong-gap-edge-point
[dygraphs.git] / src / extras / synchronizer.js
index 16c042e..bf5b6f3 100644 (file)
 /* global Dygraph:false */
 'use strict';
 
-Dygraph.synchronize = function(/* dygraphs..., opts */) {
+var Dygraph;
+if (window.Dygraph) {
+  Dygraph = window.Dygraph;
+} else if (typeof(module) !== 'undefined') {
+  Dygraph = require('../dygraph');
+}
+
+var synchronize = function(/* dygraphs..., opts */) {
   if (arguments.length === 0) {
     throw 'Invalid invocation of Dygraph.synchronize(). Need >= 1 argument.';
   }
@@ -162,7 +169,7 @@ function attachZoomHandlers(gs, syncOpts, prevCallbacks) {
         for (var j = 0; j < gs.length; j++) {
           if (gs[j] == me) {
             if (prevCallbacks[j] && prevCallbacks[j].drawCallback) {
-              prevCallbacks[j].drawCallback(me, initial);
+              prevCallbacks[j].drawCallback.apply(this, arguments);
             }
             continue;
           }
@@ -170,7 +177,7 @@ function attachZoomHandlers(gs, syncOpts, prevCallbacks) {
         }
         block = false;
       }
-    }, false /* no need to redraw */);
+    }, true /* no need to redraw */);
   }
 }
 
@@ -187,7 +194,7 @@ function attachSelectionHandlers(gs, prevCallbacks) {
         for (var i = 0; i < gs.length; i++) {
           if (me == gs[i]) {
             if (prevCallbacks[i] && prevCallbacks[i].highlightCallback) {
-              prevCallbacks[i].highlightCallback(event, x, points, row, seriesName);
+              prevCallbacks[i].highlightCallback.apply(this, arguments);
             }
             continue;
           }
@@ -205,7 +212,7 @@ function attachSelectionHandlers(gs, prevCallbacks) {
         for (var i = 0; i < gs.length; i++) {
           if (me == gs[i]) {
             if (prevCallbacks[i] && prevCallbacks[i].unhighlightCallback) {
-              prevCallbacks[i].unhighlightCallback(event);
+              prevCallbacks[i].unhighlightCallback.apply(this, arguments);
             }
             continue;
           }
@@ -213,8 +220,10 @@ function attachSelectionHandlers(gs, prevCallbacks) {
         }
         block = false;
       }
-    });
+    }, true /* no need to redraw */);
   }
 }
 
+Dygraph.synchronize = synchronize;
+
 })();