Commits

ipanema committed 957f060

New feature: synchronize a cursor between two plots (by using syncCursor method - similar to zoomProxy)

Comments (0)

Files changed (1)

src/plugins/jqplot.cursor.js

             targetPlot.resetZoom();
         }
     };
+	
+	// Function used to synchronize cursor between two chart.
+    // This method was added to jqplot to add this feature.
+    $.jqplot.Cursor.syncCursor = function(firstPlot, secondPlot) {
+    	
+        secondPlot.target.bind('jqplotMouseMove', mouseMoveFirstPlot);
+        secondPlot.target.bind('jqplotMouseEnter', mouseEnterFirstPlot);
+        secondPlot.target.bind('jqplotMouseLeave', mouseLeaveFirstPlot);
+        
+        firstPlot.target.bind('jqplotMouseMove', mouseMoveSecondPlot);
+        firstPlot.target.bind('jqplotMouseEnter', mouseEnterSecondPlot);
+        firstPlot.target.bind('jqplotMouseLeave', mouseLeaveSecondPlot);
+        
+        function mouseMoveFirstPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseMove(ev, gridPos, dataPos, neighbor, firstPlot);
+        }
+        
+        function mouseEnterFirstPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseEnter(ev, gridPos, dataPos, neighbor, firstPlot);
+        }
+
+        function mouseLeaveFirstPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseLeave(ev, gridPos, dataPos, neighbor, firstPlot);
+        }
+        
+        function mouseMoveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseMove(ev, gridPos, dataPos, neighbor, secondPlot);
+        }
+
+        function mouseEnterSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseEnter(ev, gridPos, dataPos, neighbor, secondPlot);
+        }
+
+        function mouseLeaveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+        	handleMouseLeave(ev, gridPos, dataPos, neighbor, secondPlot);
+        }
+    };
     
     $.jqplot.Cursor.prototype.resetZoom = function(plot, cursor) {
         var axes = plot.axes;