Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to improve the speed of multi curve drawing

Solved!
Go to solution

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> ; 

0 Kudos
Message 1 of 3
(1,200 Views)
Solution
Accepted by topic author shmily0923

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
0 Kudos
Message 2 of 3
(1,161 Views)
Thank you very much. The method of using addrange speeds up a lot.
0 Kudos
Message 3 of 3
(1,148 Views)