statistics: save chart in axis class

The chart was passed as argument to the function recalculating
the axis labels. Instead, pass the chart in the constructor of
the axes and save it. This gains us flexibility for the future:
There will be more functions that need to access the chart (e.g.
resizing of the axes).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-04 17:16:13 +01:00 committed by Dirk Hohndel
parent 76136010bf
commit 23d781deba
3 changed files with 35 additions and 30 deletions

View file

@ -86,7 +86,7 @@ StatsView::~StatsView()
void StatsView::plotAreaChanged(const QRectF &)
{
for (auto &axis: axes)
axis->updateLabels(chart);
axis->updateLabels();
for (auto &series: series)
series->updatePositions();
for (QuartileMarker &marker: quartileMarkers)
@ -142,9 +142,9 @@ void StatsView::setTitle(const QString &s)
template <typename T, class... Args>
T *StatsView::createAxis(const QString &title, Args&&... args)
{
T *res = new T(std::forward<Args>(args)...);
T *res = new T(chart, std::forward<Args>(args)...);
axes.emplace_back(res);
axes.back()->updateLabels(chart);
axes.back()->updateLabels();
axes.back()->qaxis()->setTitleText(title);
return res;
}