QCustomPlot Discussion and Comments

Replot causes application to freezeReturn to overview

I have an application where a plot the real time data on Qcustomplot. I have found that the plot freezes when data points increases more than 3000.

I have created two sample functions to test this and found the similar issue in both. As soon as the value of i reaches more than 2500 the plot freezes and it refreshes at end when i = 50000. I think I might be doing something wrong here.

void tempPlotData()
{  

    plots[0]->addGraph();
    dataContainer = QSharedPointer<QCPGraphDataContainer>(new QCPGraphDataContainer);
    for(unsigned int i=0; i<=50000; i++)
    {        dataContainer->add(QCPGraphData(i,i));
        plots[0]->graph(0)->setData(dataContainer);
        plots[0]->rescaleAxes();
        plots[0]->replot();        
    }
}

void tempPlotData()
{
    plots[0]->addGraph();
    plots[0]->xAxis->setRange(0,100);
    plots[0]->yAxis->setRange(0,100);    

    for(unsigned int i=0; i<=50000; i++)
    {
        plots[0]->graph(0)->addData(i,i);
        plots[0]->rescaleAxes();
        plots[0]->replot();
    }
}

Can someone please help me to find the issue?

Thanks

oh jeeze. you cant do that.

you should only call rescaleAxes and replot once per graph. you are currently forcing 50000 redraws each time you get new data.

in the for loop, you add the data, outside the loop you call the other two functions.

Thanks for the reply Ian.

Actually these are the temporary function I created to test this. If I don't call rescaleAxes and replot every time then how do I do the real time plotting?

In my original code I receive the signal value every 10 ms and I need to update the graph with the new value. In one run of my test I would need to plot at least 10000 data points of signal. I need to plot 10 signals with 10000 data points on 10 plots.

Could you please suggest the right way to do it?

Thank you

your users wont be able to see it if you update every 10ms. what i suggest is add data on the 10ms timer and rescale/replot every 500-1000ms. If you dont do it this way, your other alternative would be to do fancy work with layers, which is difficult.

Got it. Thanks for the advice Ian.