diff --git a/apps/regression/store.cpp b/apps/regression/store.cpp index affa87737..98debe7f0 100644 --- a/apps/regression/store.cpp +++ b/apps/regression/store.cpp @@ -61,7 +61,9 @@ int Store::closestVerticalDot(int direction, double x, double y, int currentSeri double currentY = i < numberOfPoints ? m_data[series][1][i] : meanOfColumn(series, 1); if (m_xMin <= currentX && currentX <= m_xMax // The next dot is within the window abscissa bounds && (std::fabs(currentX - x) <= std::fabs(nextX - x)) // The next dot is the closest to x in abscissa - && ((currentY >= y) == (direction > 0)) // The next dot is above/under y + && ((currentY > y && direction > 0) // The next dot is above/under y + || (currentY < y && direction < 0) + || (currentY == y && (currentDot < 0 || ((direction < 0) == (series > currentSeries))))) && (nextX != currentX // Edge case: if 2 dots have the same abscissa but different ordinates || ((currentY <= nextY) == (direction > 0)))) {