mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Guarded cases when min and max values of charts are equal.
This commit is contained in:
parent
a79e025151
commit
79662dffa4
3 changed files with 16 additions and 3 deletions
|
@ -80,6 +80,13 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
||||||
}
|
}
|
||||||
result.measure();
|
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();
|
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);
|
maxValueFull = std::max(int(l.maxValue * r), maxValueFull);
|
||||||
minValueFull = std::min(int(l.minValue * r), minValueFull);
|
minValueFull = std::min(int(l.minValue * r), minValueFull);
|
||||||
}
|
}
|
||||||
|
if (maxValue == minValue) {
|
||||||
|
maxValue = chartData.maxValue;
|
||||||
|
minValue = chartData.minValue;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
.full = Limits{ float64(minValueFull), float64(maxValueFull) },
|
.full = Limits{ float64(minValueFull), float64(maxValueFull) },
|
||||||
.ranged = Limits{ float64(minValue), float64(maxValue) },
|
.ranged = Limits{ float64(minValue), float64(maxValue) },
|
||||||
|
|
|
@ -167,9 +167,11 @@ AbstractChartView::HeightLimits StackChartView::heightLimits(
|
||||||
_cachedHeightLimits.ySum);
|
_cachedHeightLimits.ySum);
|
||||||
_cachedHeightLimits.full = { 0., float64(maxValueFull) };
|
_cachedHeightLimits.full = { 0., float64(maxValueFull) };
|
||||||
}
|
}
|
||||||
const auto max = _cachedHeightLimits.ySumSegmentTree.rMaxQ(
|
const auto max = std::max(
|
||||||
xIndices.min,
|
_cachedHeightLimits.ySumSegmentTree.rMaxQ(
|
||||||
xIndices.max);
|
xIndices.min,
|
||||||
|
xIndices.max),
|
||||||
|
1);
|
||||||
return {
|
return {
|
||||||
.full = _cachedHeightLimits.full,
|
.full = _cachedHeightLimits.full,
|
||||||
.ranged = { 0., float64(max) },
|
.ranged = { 0., float64(max) },
|
||||||
|
|
Loading…
Add table
Reference in a new issue