PDA

View Full Version : scatterseries getIndex bug



sboulard
17 Oct 2016, 12:32 AM
Hi,

I would like to report a bug in scatterseries class. (GXT 4.0.1)

I create scatterseries with tooltip using scatterSerie.addSeriesItemOverHandler to render the tooltips.

All is right until my listStore contains Double.NaN values. Unfortunately there is no test on "coordinates" values in get index method.

so I fixed it overridding the getIndex method as follows (adding a check on coodinates values (null)::

@Override
protected int getIndex(PrecisePoint point) {
int bestMatchIndex = -1;
double bestDistance = Double.MAX_VALUE;
double selectionToleranceSq = selectionTolerance * selectionTolerance;
for (int i = 0; i < coordinates.length; i++) {
PrecisePoint coordinate = coordinates[i];
// bug GXT: no check on coordinates ?
if (coordinate == null) {
continue;
}
double distanceSq = Math.pow(coordinate.getX() - point.getX(), 2) + Math.pow(coordinate.getY() - point.getY(), 2);
if (distanceSq < selectionToleranceSq && distanceSq < bestDistance) {
bestMatchIndex = i;
bestDistance = distanceSq;
}
}
return bestMatchIndex;
}


BR,
Sylvain