Skip to content

Commit 6e13149

Browse files
committed
Fix: Pinned ranges didn't always work on empty charts
1 parent 2c345bc commit 6e13149

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/stats/chart.cpp

+19-7
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void TimeScatterChart::updateData(const QList<DateScatterSeries*>& seriesData, Q
699699
break;
700700
}
701701
}
702-
if (noData) {
702+
if (noData && !usePinnedRanges) {
703703
reset();
704704
return;
705705
}
@@ -877,7 +877,7 @@ void HistogramChart::reset()
877877
barSet->remove(0, barSet->count());
878878
hasData = false;
879879
for (const bool p : {false, true}) {
880-
maxY [p] = 0;
880+
maxY[p] = 0;
881881
}
882882
resetAxis(yAxis, true);
883883
}
@@ -914,15 +914,21 @@ void HistogramChart::updateData(QList<qreal> histogramData, qreal newMaxY, bool
914914
}
915915
}
916916
if (noData) {
917-
reset();
917+
if (usePinnedRanges) {
918+
barSet->remove(0, barSet->count());
919+
hasData = true;
920+
updateView();
921+
} else {
922+
reset();
923+
}
918924
return;
919925
}
920926
assert(newMaxY > 0);
921927

922928
for (int p = 0; p < (setPinnedRanges ? 2 : 1); p++) {
923929
maxY[p] = newMaxY;
924930
}
925-
931+
926932
hasData = true;
927933
updateView();
928934

@@ -938,7 +944,7 @@ void HistogramChart::updateView()
938944
if (!hasData) return;
939945

940946
const bool p = usePinnedRanges;
941-
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().width(), rangeBufferFactorY);
947+
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().width(), rangeBufferFactorY);
942948
}
943949

944950

@@ -1026,7 +1032,13 @@ void TopNChart::updateData(QStringList labels, QList<qreal> values, bool setPinn
10261032
assert(labels.size() <= n);
10271033

10281034
if (values.isEmpty()) {
1029-
reset();
1035+
if (usePinnedRanges) {
1036+
barSet->remove(0, barSet->count());
1037+
hasData = true;
1038+
updateView();
1039+
} else {
1040+
reset();
1041+
}
10301042
return;
10311043
}
10321044

@@ -1057,7 +1069,7 @@ void TopNChart::updateView()
10571069
if (!hasData) return;
10581070

10591071
const bool p = usePinnedRanges;
1060-
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().width(), rangeBufferFactorY);
1072+
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().width(), rangeBufferFactorY);
10611073
}
10621074

10631075

0 commit comments

Comments
 (0)