dygraphs
dygraphs copied to clipboard
Selection bug with duplicate x axis values
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.