Guarded cases when min and max values of charts are equal.
This commit is contained in:
parent
a79e025151
commit
79662dffa4
|
@ -80,6 +80,13 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
|||
}
|
||||
result.measure();
|
||||
}
|
||||
if (result.maxValue == result.minValue) {
|
||||
if (result.minValue) {
|
||||
result.minValue = 0;
|
||||
} else {
|
||||
result.maxValue = 1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const auto subchart = root.value(u"subchart"_q).toObject();
|
||||
|
|
|
@ -256,6 +256,10 @@ AbstractChartView::HeightLimits LinearChartView::heightLimits(
|
|||
maxValueFull = std::max(int(l.maxValue * r), maxValueFull);
|
||||
minValueFull = std::min(int(l.minValue * r), minValueFull);
|
||||
}
|
||||
if (maxValue == minValue) {
|
||||
maxValue = chartData.maxValue;
|
||||
minValue = chartData.minValue;
|
||||
}
|
||||
return {
|
||||
.full = Limits{ float64(minValueFull), float64(maxValueFull) },
|
||||
.ranged = Limits{ float64(minValue), float64(maxValue) },
|
||||
|
|
|
@ -167,9 +167,11 @@ AbstractChartView::HeightLimits StackChartView::heightLimits(
|
|||
_cachedHeightLimits.ySum);
|
||||
_cachedHeightLimits.full = { 0., float64(maxValueFull) };
|
||||
}
|
||||
const auto max = _cachedHeightLimits.ySumSegmentTree.rMaxQ(
|
||||
const auto max = std::max(
|
||||
_cachedHeightLimits.ySumSegmentTree.rMaxQ(
|
||||
xIndices.min,
|
||||
xIndices.max);
|
||||
xIndices.max),
|
||||
1);
|
||||
return {
|
||||
.full = _cachedHeightLimits.full,
|
||||
.ranged = { 0., float64(max) },
|
||||
|
|
Loading…
Reference in New Issue