01-27-2013 08:18 PM
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!
Solved! Go to Solution.
01-28-2013 10:06 AM
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.
01-28-2013 09:40 PM
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?
01-29-2013 02:25 PM
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?