From: Stanislav Chachkov Date: Wed, 10 Nov 2010 15:57:16 +0000 (+0100) Subject: add row number to highlightCallback params X-Git-Tag: v1.0.0~612^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=2ddb11979071a7d1168a456c4b5cd487477f1c5e;p=dygraphs.git add row number to highlightCallback params --- diff --git a/dygraph.js b/dygraph.js index 0893f65..944faf7 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1200,7 +1200,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)); } } @@ -1211,6 +1211,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 diff --git a/tests/callback.html b/tests/callback.html index 484689a..04ed8ea 100644 --- a/tests/callback.html +++ b/tests/callback.html @@ -36,7 +36,7 @@