diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index 049942d..d78aaf2 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -805,9 +805,9 @@ void AbstractSeriesChart::updateMinAndMaxValues() } qreal maxYValue = 0; - qreal minYValue = 0; + qreal minYValue = std::numeric_limits::max(); qreal maxXValue = 0; - qreal minXValue = 0; + qreal minXValue = std::numeric_limits::max(); for (SeriesItem* series : m_chartItem->series()){ for (qreal value : series->data()->values()){ diff --git a/limereport/lraxisdata.cpp b/limereport/lraxisdata.cpp index 80a6cf3..f256fb9 100644 --- a/limereport/lraxisdata.cpp +++ b/limereport/lraxisdata.cpp @@ -132,7 +132,7 @@ void AxisData::calculateRoundedAxisScale() qreal temporaryMin = 0; qreal temporaryMax = 0; if (calculateMinimum) { - temporaryMin = qMax(0.0, minValue()); + temporaryMin = qMin(0.0, minValue()); } else { temporaryMin = qMin(manualMinimum(), minValue()); } @@ -214,7 +214,10 @@ void AxisData::calculateRoundedAxisScale() m_segmentCount = static_cast(round((currentAxisMaximum - currentAxisMinimum) / m_step)); m_rangeMin = currentAxisMinimum; m_rangeMax = currentAxisMaximum; - isLoopFinished = m_segmentCount <= maximumSegmentCount; + // Check also if step is correctly calucalted. It is possible for float steps that + // there might be a difference. Recalculate the step in that case. + const qreal tmpStep = (m_rangeMax - m_rangeMin) / m_segmentCount; + isLoopFinished = m_segmentCount <= maximumSegmentCount && qFuzzyCompare(tmpStep, m_step); if (!isLoopFinished) { // Configured step may be invalid, calculating it automatically calculateStep = true; @@ -224,8 +227,12 @@ void AxisData::calculateRoundedAxisScale() void AxisData::calculateSimpleAxisScale() { + qreal min = 0; + if (m_minValue < 0) { + min = minValue(); + } m_segmentCount = 4; - const int delta = maxValue() - minValue(); + const int delta = maxValue() - min; int max = delta; while (max % m_segmentCount != 0){ max++;