Commits

ipanema  committed 4634d95

new version of the bind cursor

  • Participants
  • Parent commits 0358d1c

Comments (0)

Files changed (1)

File src/plugins/jqplot.cursor.js

         }
     };
 	
-	// Function used to synchronize cursor between two chart.
+	// Function used to bind cursors between two chart.
     // This method was added to jqplot to add this feature.
-    $.jqplot.Cursor.syncCursor = function(firstPlot, secondPlot) {
-        firstPlot.target.bind('jqplotMouseMove', mouseMoveSecondPlot);
-        firstPlot.target.bind('jqplotMouseEnter', mouseEnterSecondPlot);
-        firstPlot.target.bind('jqplotMouseLeave', mouseLeaveSecondPlot);
-        
-        function mouseMoveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
-            gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
-        	handleMouseMove(ev, gridPos, dataPos, neighbor, secondPlot);
-        }
+    $.jqplot.Cursor.bindCursor = function(firstPlot, secondPlot) {
+		var firstPlotCursor= firstPlot.plugins.cursor;
+		var secondPlotCurosr = secondPlot.plugins.cursor;
+		if (firstPlotCursor._tooltipElem && secondPlotCurosr._tooltipElem) {
+			function mouseMoveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+				gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
+				handleMouseMove(ev, gridPos, dataPos, neighbor, secondPlot);
+			}
 
-        function mouseEnterSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
-            gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
-        	handleMouseEnter(ev, gridPos, dataPos, neighbor, secondPlot);
-        }
+			function mouseEnterSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+				gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
+				handleMouseEnter(ev, gridPos, dataPos, neighbor, secondPlot);
+			}
 
-        function mouseLeaveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
-            gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
-        	handleMouseLeave(ev, gridPos, dataPos, neighbor, secondPlot);
-        }
+			function mouseLeaveSecondPlot(ev, gridPos, dataPos, neighbor, plot) {
+				gridPos.x = secondPlot.axes.xaxis.series_u2p(dataPos.xaxis);
+				handleMouseLeave(ev, gridPos, dataPos, neighbor, secondPlot);
+			}	
+		
+			firstPlot.target.bind('jqplotMouseMove', mouseMoveSecondPlot);
+			firstPlot.target.bind('jqplotMouseEnter', mouseEnterSecondPlot);
+			firstPlot.target.bind('jqplotMouseLeave', mouseLeaveSecondPlot);
+			
+			return true;
+		}
+		
+		return false;
+    };
+	
+	// Function used to unbind cursors between two chart.
+    // This method was added to jqplot to add this feature.
+    $.jqplot.Cursor.unbindCursor = function(plot) {
+		plot.target.unbind();
     };
     
     $.jqplot.Cursor.prototype.resetZoom = function(plot, cursor) {
         if (this.show) {
             var series = this._series, s;
             // make a table.  one line label per row.
-            var elem = document.createElement('div');
+            var elem = document.createElement('table');
             this._elem = $(elem);
             elem = null;
             this._elem.addClass('jqplot-legend jqplot-cursor-legend');