Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

[WPF]How to forbid the graph creating plot automatically

Solved!
Go to solution

Hi, all.

I'm using the mvvm to write a program. The problem is the count of PlotCollection in xaml.cs file is always 0 after the graph control is created, but there is a plot in the graph which is automatically created. Also I want to add plots manually after the graph is created. I did it in the xaml.cs like this:

            Plot newplot = new Plot();
            newplot.Renderer= new LinePlotRenderer(){Stroke=splot.Color,StrokeThickness=0.5};
            m_Graph.Plots.Add(newplot);

 Then the plots' count always equals the datasource's count minus one. How to solve this problem?

 

Thanks in advance!

0 Kudos
Message 1 of 4
(6,469 Views)

The WPF graph controls are data-driven, so they will automatically create default plots and scales if you do not provide them. However, plots and scales added to the graphs will always take precedence over the default ones.


So to control the plots used by the graph, simply add the same number of plots as you have data in your data source. You do not need to remove or configure the default plot, as it will not be used if you provide the plots yourself.

~ Paul H
0 Kudos
Message 2 of 4
(6,456 Views)

Thanks, Paul.

I'm using an array to store the plots' propertys such as data, color etc. What you said means I should construct a single array to store the color property and so on. Am I right?

0 Kudos
Message 3 of 4
(6,446 Views)
Solution
Accepted by topic author darkeria

I think I may have misunderstood your initial situation. It sounds like you have an array of a “plot info” type that contains line color, data, etc, for each plot. If you populate the Plots collection with plots created with this info, and at the same time populate the Data collection with the data associated with each plot, then the graph should display your data using your plots, and there should be no extra plots left in the graph.


If that is not the case, would you mind posting the code you use to update the graph?

~ Paul H
0 Kudos
Message 4 of 4
(6,439 Views)