I apologize for asking so many OxyPlot questions, but it seems to me that I'm really struggling with using the OxyPlot chart control.
My project is in WPF format, so I initially used the hosted WINFORMS diagram, which worked like a charm and did absolutely everything that I needed until I had to overlay the WPF element on top of the hosted winform diagram. Due to the "AirSpace" problem, I could not see the WPF element that I placed on top of the posted chart, no matter what I did. That's when I decided to go with OxyPlot, which still causes me a lot of headache.
Here is my [original question] [2]! what I asked at CodePlex. It seems to me that they donβt really help there, so I'm trying here again.
My question is:
Does anyone know how to apply MULTIPLE LineSeries onto a site ??
My approach so far:
I take an array of c # List and add a new copy of LineSeries, which contains the new data that should be plotted. My code is:
// Function to plot data private void plotData(double numWeeks, double startingSS) { // Initialize new Salt Split class for acess to data variables Salt_Split_Builder calcSS = new Salt_Split_Builder(); calcSS.compute(numWeeks, startingSS, maxDegSS); // Create the OxyPlot graph for Salt Split OxyPlot.Wpf.PlotView plot = new OxyPlot.Wpf.PlotView(); var model = new PlotModel(); // Add Chart Title model.Title = "Salt Split Degradation"; // Create new Line Series LineSeries linePoints = new LineSeries() { StrokeThickness = 1, MarkerSize = 1, Title = numWeeks.ToString() + " weeks" }; // Add each point to the new series foreach (var point in calcSS.saltSplitCurve) { DataPoint XYpoint = new DataPoint(); XYpoint = new DataPoint(point.Key, point.Value * 100); linePoints.Format("%", XYpoint.Y); linePoints.Points.Add(XYpoint); } listPointAray.Add(linePoints); // Define X-Axis var Xaxis = new OxyPlot.Axes.LinearAxis(); Xaxis.Maximum = numWeeks; Xaxis.Minimum = 0; Xaxis.Position = OxyPlot.Axes.AxisPosition.Bottom; Xaxis.Title = "Number of Weeks"; model.Axes.Add(Xaxis); //Define Y-Axis var Yaxis = new OxyPlot.Axes.LinearAxis(); Yaxis.MajorStep = 15; Yaxis.Maximum = calcSS.saltSplitCurve.Last().Value * 100; Yaxis.MaximumPadding = 0; Yaxis.Minimum = 0; Yaxis.MinimumPadding = 0; Yaxis.MinorStep = 5; Yaxis.Title = "Percent Degradation"; model.Axes.Add(Yaxis); // Add Each series to the foreach (var series in listPointAray) { LineSeries newpoints = new LineSeries(); newpoints = linePoints; model.Series.Add(newpoints); } // Add the plot to the window plot.Model = model; SaltSplitChartGrid.Children.Add(plot); }
My code works the first time I press my "Graph Data" button, but fails on consecutive attempts with the following error: > The element cannot be added, it already belongs to a Plot Model The following plot is the type of plot I would like to produce (it worked fine using WinForms Chart control): [![Image][1]][1] <!
c # charts wpf oxyplot
John august
source share