[statistics] Fix glitch with histogram parameters

In the window to change the histogram parameters, it was possible to set
a rectangle width that was considered valid, but would make the starting
abscissa invalid, while triggering no error message. The message would
only show if the user closed the window and opened it again.
e.g. : Set a series with only one value 1e10
       Change its starting abscissa to 0
       Change its rectangle width to 1, confirm and close the menu
       Re-open the menu, a message appears, and stays onscreen when
leaving the menu.
This commit is contained in:
Gabriel Ozouf
2020-12-28 16:19:16 +01:00
committed by EmilieNumworks
parent ea4770fc81
commit 5ce5f4fbac

View File

@@ -90,7 +90,7 @@ bool HistogramParameterController::setParameterAtIndex(int parameterIndex, doubl
// The number of bars cannot be above the max
assert(DoublePairStore::k_numberOfSeries > 0);
for (int i = 0; i < DoublePairStore::k_numberOfSeries; i++) {
const double min = setBarWidth ? m_store->minValue(i) : nextFirstDrawnBarAbscissa;
const double min = std::min(m_store->minValue(i), nextFirstDrawnBarAbscissa);
double numberOfBars = std::ceil((m_store->maxValue(i) - min)/nextBarWidth);
if (numberOfBars > Store::k_maxNumberOfBars) {
Container::activeApp()->displayWarning(I18n::Message::ForbiddenValue);