[apps/regression] Improve vertical navigation

Data set:
X1 2 3 2   1
Y1 0 1 0.5 5
X2 1 10 2
Y2 0 25 0.5

There was circular navigation on series 2 mean point
This commit is contained in:
Léa Saviot
2018-12-13 14:27:21 +01:00
committed by EmilieNumworks
parent 99d97ecb45
commit 42cdf95e9f
2 changed files with 3 additions and 2 deletions

View File

@@ -315,7 +315,7 @@ bool GraphController::moveCursorVertically(int direction) {
double dotDistanceY = (dotSelected == m_store->numberOfPairsOfSeries(closestDotSeries)) ?
std::fabs(m_store->meanOfColumn(closestDotSeries, 1) - y) :
std::fabs(m_store->get(closestDotSeries, 1, dotSelected) - y);
if (regressionDistanceY < dotDistanceY) {
if (regressionDistanceY <= dotDistanceY) {
validDot = false;
} else {
validRegression = false;

View File

@@ -63,7 +63,8 @@ int Store::closestVerticalDot(int direction, double x, double y, int currentSeri
&& (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)
|| (currentY == y && (currentDot < 0 || ((direction < 0) == (series > currentSeries)))))
|| (currentY == y
&& ((currentDot < 0 && direction > 0)|| ((direction < 0) == (series > currentSeries)))))
&& (nextX != currentX // Edge case: if 2 dots have the same abscissa but different ordinates
|| ((currentY <= nextY) == (direction > 0))))
{