dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

Selection bug with duplicate x axis values

Open squaregoldfish opened this issue 6 years ago • 0 comments

If you have a data set with multiple points at the same x axis value, setSelection and getSelection don't behave as they should.

A jsfiddle illustrating this is here: https://jsfiddle.net/squaregoldfish/Lgc9b06o/

If you select 2, getSelection() reports 1.

The cause is getSelection - it loops through all the rows and returns the idx of the first row it finds with the same x value. I'm not sure what the logic is behind this, when you can just get the first selected point and return its idx as follows:

Dygraph.prototype.getSelection = function() {
  if (!this.selPoints_ || this.selPoints_.length < 1) {
    return -1;
  } else {
    return this.selPoints_[0].idx;
  }
};

Is there something I'm missing?

I can fix this as part of the changes I'm making for #371, since it has implications there.

squaregoldfish avatar Feb 28 '18 17:02 squaregoldfish