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));
}
}
};
/**
+ * 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
<script type="text/javascript">
s = document.getElementById("status");
g = null;
- pts_info = function(e, x, pts) {
+ pts_info = function(e, x, pts, row) {
var str = "(" + x + ") ";
for (var i = 0; i < pts.length; i++) {
var p = pts[i];
var dataXY = g.toDataCoords(x, y);
str += ", (" + x + ", " + y + ")";
str += " -> (" + dataXY[0] + ", " + dataXY[1] + ")";
+ str += ", row #"+row;
return str;
};
showRoller: true,
errorBars: true,
- highlightCallback: function(e, x, pts) {
+ highlightCallback: function(e, x, pts, row) {
if (document.getElementById('highlight').checked) {
- s.innerHTML += "<b>Highlight</b> " + pts_info(e,x,pts) + "<br/>";
+ s.innerHTML += "<b>Highlight</b> " + pts_info(e,x,pts,row) + "<br/>";
}
},