Merge https://github.com/stani/dygraphs
[dygraphs.git] / dygraph.js
index 7384e71..1f36f1c 100644 (file)
@@ -1203,7 +1203,7 @@ Dygraph.prototype.mouseMove_ = function(event) {
     var px = this.lastx_;
     if (px !== null && lastx != px) {
       // only fire if the selected point has changed.
-      this.attr_("highlightCallback")(event, lastx, this.selPoints_);
+      this.attr_("highlightCallback")(event, lastx, this.selPoints_, this.idxToRow_(idx));
     }
   }
 
@@ -1214,6 +1214,25 @@ Dygraph.prototype.mouseMove_ = function(event) {
 };
 
 /**
+ * Transforms layout_.points index into data row number
+ * @param int layout_.points index
+ * @return int row number
+ * @private
+ */
+Dygraph.prototype.idxToRow_ = function(idx) {
+       if(idx<0)return -1;
+
+       for (var i in this.layout_.datasets) {
+               if (idx < this.layout_.datasets[i].length) {
+                       return this.boundaryIds_[0][0]+idx;
+               }
+               idx-=this.layout_.datasets[i].length;
+       }
+       return -1;
+}
+
+
+/**
  * Draw dots over the selectied points in the data series. This function
  * takes care of cleanup of previously-drawn dots.
  * @private