getMinimumDistance method

double getMinimumDistance(
  1. List<Highlight> closestValues,
  2. double pos,
  3. AxisDependency axis
)

Returns the minimum distance from a touch value (in pixels) to the closest value (in pixels) that is displayed in the chart.

@param closestValues @param pos @param axis @return

Implementation

double getMinimumDistance(
    List<Highlight> closestValues, double pos, AxisDependency axis) {
  double distance = double.infinity;

  for (int i = 0; i < closestValues.length; i++) {
    Highlight high = closestValues[i];

    if (high.axis == axis) {
      double tempDistance = (getHighlightPos(high)! - pos).abs();
      if (tempDistance < distance) {
        distance = tempDistance;
      }
    }
  }

  return distance;
}