X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=5cfe2f424e0ce7af87ab1b45c696dab168b119aa;hb=1903f1e49133d38479059befb9dc50c7b622c826;hp=f736a7e6d4999fe5008a9e70fcc135be379de6fc;hpb=3a8dc464e8e7b197d7df18220ab2ad189ff95841;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index f736a7e..5cfe2f4 100644 --- a/dygraph.js +++ b/dygraph.js @@ -189,10 +189,10 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { // If the div isn't already sized then inherit from our attrs or // give it a default size. if (div.style.width == '') { - div.style.width = attrs.width || Dygraph.DEFAULT_WIDTH + "px"; + div.style.width = (attrs.width || Dygraph.DEFAULT_WIDTH) + "px"; } if (div.style.height == '') { - div.style.height = attrs.height || Dygraph.DEFAULT_HEIGHT + "px"; + div.style.height = (attrs.height || Dygraph.DEFAULT_HEIGHT) + "px"; } this.width_ = parseInt(div.style.width, 10); this.height_ = parseInt(div.style.height, 10); @@ -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,24 @@ Dygraph.prototype.mouseMove_ = function(event) { }; /** + * Transforms layout_.points index into data row number. + * @param int layout_.points index + * @return int row number, or -1 if none could be found. + * @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