Hi there!
I have a realtime plot with 4 graphs and with a ton of data. The vectors get sent to the plot every ~5 sec.
Currently, I am plotting a total of 20 seconds by removing the oldest 5 sec from the plot with removeBefore
.
I tested the code with addData
and withsetData
, but both result in a total of about 600ms to plot. There is no difference in perfomance whether I use add or set Data which I find surprinsing. renew_plot_data is called every 5 seconds.
renew_plot_data:
QElapsedTimer timer; timer.start(); for(int i=0; i<6; i++) { if(Active[i]) { actualWidget->graph(i)->setVisible(Active[i]); actualWidget->graph(i)->data()->removeBefore(key - (MAX_REPS - 1)* TIME_BASE ); actualWidget->graph(i)->addData(time, data_plot[InvNum[i]][ParNum[i]]); actualWidget->graph(i)->setName(StrNum[i]); actualWidget->graph(i)->addToLegend(); } } actualWidget->xAxis->rescale(true); actualWidget->replot(); qDebug()<< "all in all plot data took " << timer.elapsed() << " ms."; qDebug() << "end for.";
but this results in the same performance (if in both cases only 5sec are shown)
QElapsedTimer timer; timer.start(); for(int i=0; i<6; i++) { if(Active[i]) { actualWidget->graph(i)->setVisible(Active[i]); actualWidget->graph(i)->setData(time, data_plot[InvNum[i]][ParNum[i]]); actualWidget->graph(i)->setName(StrNum[i]); actualWidget->graph(i)->addToLegend(); } } actualWidget->xAxis->rescale(true); actualWidget->replot(); qDebug()<< "all in all plot data took " << timer.elapsed() << " ms."; qDebug() << "end for.";
From my understanding, addData should result in a better performance.
I try to reduce the replotting time as during that time the graph cannot be moved neither comboboxes or checkboxes can be clicked, resulting in a feelable lag.
Thank you in advance!
Best