NicolasCasime

23rd May 2018, 15:49

Hi everybody!

Im having some trouble using QtCharts.

My application needs to plot some linear graphs. I have the data contained on an Array.

I need to plot between 100 and 20000 points or so.

On my .h

QChart *Chart;

QLineSeries *Serie;

QChartView *View;

How I Initialize everything

void Initialize(void)

{

Serie=new QLineSeries();

Chart=new QChart();

Chart->legend()->hide();

Chart->addSeries(Serie);

Chart->createDefaultAxes();

View= new QChartView(Chart);

View->setRenderHint(QPainter::Antialiasing);

}

Now lets assume I want to plot 10000 points (I dont care about the value)

void Plot(void)

{

//------------Reset-------------------

Serie->clear();

//---------------------------------------

for(long int i=0;i<10000;i++)

{

QApplication::processEvents();

Serie->append(i,i+10);//Right now I dont care about the value

}

Chart->removeSeries(Serie);

Chart->addSeries(Serie);

}

That "for" loops takes like 20 seconds to complete. Freezing all of my program.

Im not doing anything weird, just calling the append method of a QLineSeries.

Am i doing something wrong?

Is there a way to append 10K points and not having to wait so much?

The final Chart looks exactly as i want it to look. Its just that I wait that much each time I need to plot some data

Any ideas?

Thanks in advance

Added after 21 minutes:

UPDATE:

I have read that you can call the setUseOpenGL() method of the LineSeries to make it faster.

On my example, it has the opposite effect. If i activate the OpenGL, the for will take even longer to finish.

Added after 14 minutes:

Another Update:

In order to understand why it takes So long to plot. I placed a progressbar which increases as the for loop advances.

The results where quite strange.

The time it takes to complete that for is not Linear!

What do i mean?

The beggining of the for is done extremely fast. As "i" advences, each time the append operation takes more time.

Lets make a basic example. If on my computer takes 20 seconds to complete that for sequence...

After 5 seconds: 50 % of the Graph plotted

After 10 seconds: 80% of the Graph plotted

After 15 seconds:n 95% of the Graph plotted

Why does this happen?

The insertion time of a list is always the same, It doesnt matter how much nodes that list has...

Im having some trouble using QtCharts.

My application needs to plot some linear graphs. I have the data contained on an Array.

I need to plot between 100 and 20000 points or so.

On my .h

QChart *Chart;

QLineSeries *Serie;

QChartView *View;

How I Initialize everything

void Initialize(void)

{

Serie=new QLineSeries();

Chart=new QChart();

Chart->legend()->hide();

Chart->addSeries(Serie);

Chart->createDefaultAxes();

View= new QChartView(Chart);

View->setRenderHint(QPainter::Antialiasing);

}

Now lets assume I want to plot 10000 points (I dont care about the value)

void Plot(void)

{

//------------Reset-------------------

Serie->clear();

//---------------------------------------

for(long int i=0;i<10000;i++)

{

QApplication::processEvents();

Serie->append(i,i+10);//Right now I dont care about the value

}

Chart->removeSeries(Serie);

Chart->addSeries(Serie);

}

That "for" loops takes like 20 seconds to complete. Freezing all of my program.

Im not doing anything weird, just calling the append method of a QLineSeries.

Am i doing something wrong?

Is there a way to append 10K points and not having to wait so much?

The final Chart looks exactly as i want it to look. Its just that I wait that much each time I need to plot some data

Any ideas?

Thanks in advance

Added after 21 minutes:

UPDATE:

I have read that you can call the setUseOpenGL() method of the LineSeries to make it faster.

On my example, it has the opposite effect. If i activate the OpenGL, the for will take even longer to finish.

Added after 14 minutes:

Another Update:

In order to understand why it takes So long to plot. I placed a progressbar which increases as the for loop advances.

The results where quite strange.

The time it takes to complete that for is not Linear!

What do i mean?

The beggining of the for is done extremely fast. As "i" advences, each time the append operation takes more time.

Lets make a basic example. If on my computer takes 20 seconds to complete that for sequence...

After 5 seconds: 50 % of the Graph plotted

After 10 seconds: 80% of the Graph plotted

After 15 seconds:n 95% of the Graph plotted

Why does this happen?

The insertion time of a list is always the same, It doesnt matter how much nodes that list has...