Hello.
I have a problem with QChart.
When i plot >3000 samples it goes incredibly slow. I tried plotting a signal with 16000 samples, which took 13 seconds to plot.
Here is the bit that is causing problems:
QLineSeries *lineseries = new QLineSeries();
QScatterSeries *scatterseries = new QScatterSeries();
mytimer.start();
lineseries->append(ali[bandnr].toList()); // QVector<QPointF>
scatterseries->append(ali[bandnr].toList());
chart_->addSeries(lineseries);
chart_->addSeries(scatterseries);
qDebug() << "time: " << mytimer.elapsed();
scatterseries->setMarkerSize(8);
scatterseries->setPen(Qt::NoPen); // do not make border around points
connect(scatterseries, &QScatterSeries::clicked, this, &LinePlot::keepCallout_);
connect(scatterseries,
&QScatterSeries
::hovered,
[=](QPointF point,
bool state
) {this
->tooltip_
(point, state, name
);
});
QLineSeries *lineseries = new QLineSeries();
QScatterSeries *scatterseries = new QScatterSeries();
QTime mytimer;
mytimer.start();
lineseries->append(ali[bandnr].toList()); // QVector<QPointF>
scatterseries->append(ali[bandnr].toList());
chart_->addSeries(lineseries);
chart_->addSeries(scatterseries);
qDebug() << "time: " << mytimer.elapsed();
scatterseries->setMarkerSize(8);
scatterseries->setPen(Qt::NoPen); // do not make border around points
QString name = "hello";
connect(scatterseries, &QScatterSeries::clicked, this, &LinePlot::keepCallout_);
connect(scatterseries, &QScatterSeries::hovered, [=](QPointF point, bool state) {this->tooltip_(point, state, name); });
To copy to clipboard, switch view to plain text mode
"ali" is just a QVector<QVector<QPointF>>
I read somewhere that appending the data to the QLineSeries/QScatterSeries before adding them to QChart would improve speed. But its the same.
I also read that using "replace" instead of "append" should increase the speed. But it doesn't change anything.
The reason i also add a QScatterSeries is to make my "hover" tooltip only appear on actual data points.
I also tried QCustomPlot instead, which uses 0.142 seconds to plot the same data. Why is QChart that much slower? Is there a solution to make it faster?
Best Regards
DAVC
Bookmarks