Avoid graphic flickering when changing parameters in StatsPanel

This commit is contained in:
Grégory Soutadé 2017-10-29 18:21:54 +01:00 committed by Grégory Soutadé
parent ada23a4092
commit 85338d4b70

View File

@ -176,12 +176,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
if (_chartView)
{
_vbox2->removeWidget(_chartView);
delete _chartView;
_plot->removeAllSeries();
}
_plot = new QChart();
_plot->createDefaultAxes();
else
_plot = new QChart();
if (monthFrom == monthTo && yearFrom == yearTo)
{
@ -301,9 +299,13 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
_plot->createDefaultAxes();
_plot->setAxisX(axisX, series0);
_chartView = new QChartView(_plot);
_chartView->setRenderHint(QPainter::Antialiasing);
_vbox2->addWidget(_chartView);
if (!_chartView)
{
_chartView = new QChartView(_plot);
_chartView->setRenderHint(QPainter::Antialiasing);
_vbox2->addWidget(_chartView);
}
total = 0.0;
for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)