Skip to content

Commit 979c1b2

Browse files
committed
Fix: YearBarCharts wouldn't show anything for single year range
For #191
1 parent 1ac82ca commit 979c1b2

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/stats/chart.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,6 @@ void YearBarChart::updateData(const QList<qreal>& newData, int newMinYear, int n
543543
assert(newData.size() == newMaxYear - newMinYear + 1);
544544
assert(newMaxY >= 0);
545545

546-
QStringList years = QStringList();
547-
for (int year = newMinYear; year <= newMaxYear; year++) {
548-
years.append(QString::number(year));
549-
}
550-
551546
barSet->remove(0, barSet->count());
552547
barSet->append(QList<qreal>(newMinYear, 0));
553548
barSet->append(newData);
@@ -569,8 +564,8 @@ void YearBarChart::updateView()
569564
if (!hasData) return;
570565

571566
const bool p = usePinnedRanges;
572-
adjustAxis(xAxis, minYear[p], maxYear[p], chart->plotArea().width(), rangeBufferFactorX);
573-
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().height(), rangeBufferFactorY);
567+
adjustAxis(xAxis, minYear[p] - 0.5, maxYear[p] + 0.5, chart->plotArea().width(), rangeBufferFactorX);
568+
adjustAxis(yAxis, 0, maxY[p], chart->plotArea().height(), rangeBufferFactorY);
574569
}
575570

576571

src/stats/stats_engine.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,10 @@ void GeneralStatsEngine::setupStatsTab()
214214
*/
215215
void GeneralStatsEngine::resetStatsTab()
216216
{
217-
assert(numAscentsPerYearChart);
218-
assert(elevGainPerYearChart);
219-
assert(heightsScatterChart);
220-
221-
numAscentsPerYearChart ->reset();
222-
elevGainPerYearChart ->reset();
223-
heightsScatterChart ->reset();
224-
225217
setCurrentlyVisible(false);
226218
for (Chart* const chart : qAsConst(charts)) {
219+
assert(chart);
220+
chart->reset();
227221
dirty[chart] = true;
228222
}
229223
}

0 commit comments

Comments
 (0)