mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/statistics] Fix bar width computation
There was a float -> double conversion lack of precision, which resulted in akward results Scenario: Data V N Then display the histogram: the second bar is [1.9;2[ but 1 1 contains the 2 value 2 1
This commit is contained in:
@@ -247,9 +247,14 @@ void HistogramController::initBarParameters() {
|
||||
assert(selectedSeriesIndex() >= 0 && m_store->sumOfOccurrences(selectedSeriesIndex()) > 0);
|
||||
preinitXRangeParameters();
|
||||
m_store->setFirstDrawnBarAbscissa(m_store->xMin());
|
||||
float barWidth = m_store->xGridUnit();
|
||||
if (barWidth <= 0.0f) {
|
||||
barWidth = 1.0f;
|
||||
double barWidth = m_store->xGridUnit();
|
||||
if (barWidth <= 0.0) {
|
||||
barWidth = 1.0;
|
||||
} else {
|
||||
// Truncate the bar width, as we convert from float to double
|
||||
const double precision = 7; // TODO factorize? This is an experimental value, the same as in Expression;;Epsilon<float>()
|
||||
const double logBarWidth = std::floor(std::log10(barWidth));
|
||||
barWidth = ((int)(barWidth * std::pow(10.0, precision - logBarWidth))) * std::pow(10.0, -precision + logBarWidth);
|
||||
}
|
||||
m_store->setBarWidth(barWidth);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user