Improve performance at shifting QLineSeries?
-
Hey,
I'm using QtCharts and animated the graphs. After having more than 50 values, always the oldest got removed from the series.
Here a short code overview:QVector<QPointF> points = m_temperature_series.pointsVector(); m_temperature_series.clear(); for (int i=0;i<index;i++) m_temperature_series.append(i, points.at(i+1).y());
The class of m_temperature_series is QLineSeries
It's working good but it needs too much performance. With multiple graphs and a long graph history, you have a high cpu usage. But I dont know any way to optimize this code.
I hope someone can help me out here :) -
TakeFirst is basically a good idea and it removes the first element. The problem is, that the second element at X still have the value 1 and is not decremented to 0.
Edit// Just did a short test with another code... it's working but not sure about the performance
QLineSeries Test; Test.append(0,0); Test.append(1,1); Test.append(2,2); Test.append(3,3); QList<QPointF> Points = Test.points(); Points.removeFirst(); int counter=0; QList<QPointF>::iterator i; for (i=Points.begin(); i!=Points.end();i++) { i->setX(counter); counter++; } Test.clear(); Test.append(Points);
-
How about using the model-view approach with QVXYModelMapper as shown in the model data example?