cancel
Showing results for 
Search instead for 
Did you mean: 

How to improve the speed of multi curve drawing

SOLVED
shmily0923
Member
Solved!

How to improve the speed of multi curve drawing

Deer All:

            I want to draw multiple curves on a graph. The number of curves is a variable. So I adopted the method of list < point > assignment. This method is time-consuming when the amount of data is large. 

 

Graph.Data[Chn++] = List<Point> ; 

2 REPLIES 2
phansen
NI Employee (retired)
Solution

Re: How to improve the speed of multi curve drawing

Assigning each data item individually is probably causing the graph to do some redundant re-processing as each item is assigned.

 

You can inform the graph about multiple updates by using the standard WPF BeginInit/EndInit methods:

 

Graph.BeginInit();
/* your existing code:
... Graph.Data[Chn++] = List<Point> ; ...
*/
Graph.EndInit();

 

 

Or you could assign all of the data to the graph at once:

 

var allChannelData = new List<List<Point>>();
/* your existing code, using new collection:
... allChannelData.Add( List<Point> ); ...
*/
graph.Data.AddRange( allChannelData );
// or alternatively, graph.DataSource = allChannelData;

 

 

I would also suggest comparing your graph configuration with the recommendations in the "Optimizing the WPF Graphs" help topic.

~ Paul H
shmily0923
Member

Re: How to improve the speed of multi curve drawing

Thank you very much. The method of using addrange speeds up a lot.