getClosestHighlightByPixel method
Returns the Highlight of the DataSet that contains the closest value on the y-axis.
@param closestValues contains two Highlight objects per DataSet closest to the selected x-position (determined by rounding up an down) @param x @param y @param axis the closest axis @param minSelectionDistance @return
Implementation
Highlight? getClosestHighlightByPixel(List<Highlight> closestValues, double x,
double y, AxisDependency axis, double? minSelectionDistance) {
Highlight? closest;
double? distance = minSelectionDistance;
for (int i = 0; i < closestValues.length; i++) {
Highlight high = closestValues[i];
// TODO : it was good change?
if (high.axis == axis) {
double cDistance = getDistance(x, y, high.xPx!, high.yPx!);
if (cDistance < distance!) {
closest = high;
distance = cDistance;
}
}
}
return closest;
}