public void UpdatePlotModel() { ThePlotModel = new PlotModel(); ThePlotModel.LegendTitle = "Legend"; ThePlotModel.LegendPosition = LegendPosition.TopLeft; int colorCounter = 0; if (SelectedLeftAxis != null && SelectedBottomAxis != null && SelectedRightAxis != null)//assume we always want to plot two quantities { ThePlotModel.Axes.Add((Axis)SelectedLeftAxis.DynamicInvoke(SelectedLeftAxisProperty.Item1, AxisPosition.Left)); ThePlotModel.Axes.Add((Axis)SelectedRightAxis.DynamicInvoke(SelectedRightAxisProperty.Item1, AxisPosition.Right)); ThePlotModel.Axes.Add((Axis)SelectedBottomAxis.DynamicInvoke(SelectedBottomAxisProperty.Item1, AxisPosition.Bottom)); if (TheLifetimeVM != null)//we are (probably) plotting without a link to the dataContext { LineSeries lifetimeSeries1 = new LineSeries(); LineSeries lifetimeSeries2 = new LineSeries(); lifetimeSeries1.Color = LineSeriesColors[colorCounter]; lifetimeSeries2.Color = LineSeriesColors[colorCounter]; lifetimeSeries2.LineStyle = LineStyle.Dash; lifetimeSeries2.YAxisKey = _rightAxisKey; colorCounter++; lifetimeSeries1.Title = TheLifetimeVM.CryscoFileName; PropertyInfo xprop = SelectedBottomAxisProperty.Item2; PropertyInfo y1prop = SelectedLeftAxisProperty.Item2; PropertyInfo y2prop = SelectedRightAxisProperty.Item2; foreach (CryscoLifetimeDatum cld in TheLifetimeVM.LifetimeDataList) { double xval = (double)xprop.GetValue(cld); double y1val = (double)y1prop.GetValue(cld); double y2val = (double)y2prop.GetValue(cld); lifetimeSeries1.Points.Add(new DataPoint(xval, y1val)); lifetimeSeries2.Points.Add(new DataPoint(xval, y2val)); } ThePlotModel.Series.Add(lifetimeSeries1); ThePlotModel.Series.Add(lifetimeSeries2); } else if (LifetimeVMCollection.Count > 0)//we are plotting from a collection of lifetime data entities { foreach (LifetimeVM life in LifetimeVMCollection) { LineSeries lifetimeSeries1 = new LineSeries(); LineSeries lifetimeSeries2 = new LineSeries(); lifetimeSeries1.Color = LineSeriesColors[colorCounter]; lifetimeSeries2.Color = LineSeriesColors[colorCounter]; lifetimeSeries2.LineStyle = LineStyle.Dash; lifetimeSeries2.YAxisKey = _rightAxisKey; colorCounter++; lifetimeSeries1.Title = life.TheLifetime.Pixel.Site; PropertyInfo xprop = SelectedBottomAxisProperty.Item2; PropertyInfo y1prop = SelectedLeftAxisProperty.Item2; PropertyInfo y2prop = SelectedRightAxisProperty.Item2; foreach (CryscoLifetimeDatum cld in life.LifetimeDataList) { double xval = (double)xprop.GetValue(cld); double y1val = (double)y1prop.GetValue(cld); double y2val = (double)y2prop.GetValue(cld); lifetimeSeries1.Points.Add(new DataPoint(xval, y1val)); lifetimeSeries2.Points.Add(new DataPoint(xval, y2val)); } ThePlotModel.Series.Add(lifetimeSeries1); ThePlotModel.Series.Add(lifetimeSeries2); } } ThePlotModel.InvalidatePlot(true);//do this out of superstition/ignorance } }
public void UpdatePlotModel() { ThePlotModel = new PlotModel(); ThePlotModel.LegendTitle = "Legend"; ThePlotModel.LegendPosition = LegendPosition.TopLeft; int colorCounter = 0; if (SelectedLeftAxis != null && SelectedBottomAxis != null) { if (SelectedRightAxisProperty == null || SelectedRightAxis == RightAxisDict["None"]) //we are not plotting a 2nd property { ThePlotModel.Axes.Add((Axis)SelectedLeftAxis.DynamicInvoke(SelectedLeftAxisProperty.Item1, AxisPosition.Left)); ThePlotModel.Axes.Add((Axis)SelectedBottomAxis.DynamicInvoke(SelectedBottomAxisProperty.Item1, AxisPosition.Bottom)); foreach (LJVScanVM scan in LJVScanVMCollection) { LineSeries scanSeries = new LineSeries(); scanSeries.Color = LineSeriesColors[colorCounter]; colorCounter++; if (SelectedViewStyle == ViewStyle.Regular) { scanSeries.Title = scan.TheLJVScan.Pixel.Site; } if (SelectedViewStyle == ViewStyle.Aging) { scanSeries.Title = scan.TheLJVScan.DeviceLJVScanSummary.TestCondition; } PropertyInfo xprop = SelectedBottomAxisProperty.Item2; PropertyInfo yprop = SelectedLeftAxisProperty.Item2; foreach (ProcessedLJVDatum pd in scan.ProcLJVDataList) { double xval = Convert.ToDouble((decimal)xprop.GetValue(pd)); double yval = Convert.ToDouble((decimal)yprop.GetValue(pd)); scanSeries.Points.Add(new DataPoint(xval, yval)); } ThePlotModel.Series.Add(scanSeries); } } else //plot left and right axis properties vs bottom { ThePlotModel.Axes.Add((Axis)SelectedLeftAxis.DynamicInvoke(SelectedLeftAxisProperty.Item1, AxisPosition.Left)); ThePlotModel.Axes.Add((Axis)SelectedRightAxis.DynamicInvoke(SelectedRightAxisProperty.Item1, AxisPosition.Right)); ThePlotModel.Axes.Add((Axis)SelectedBottomAxis.DynamicInvoke(SelectedBottomAxisProperty.Item1, AxisPosition.Bottom)); foreach (LJVScanVM scan in LJVScanVMCollection) { LineSeries scanSeries1 = new LineSeries(); LineSeries scanSeries2 = new LineSeries(); scanSeries2.LineStyle = LineStyle.DashDot; scanSeries1.Color = LineSeriesColors[colorCounter]; scanSeries2.Color = LineSeriesColors[colorCounter]; colorCounter++; scanSeries2.YAxisKey = _rightAxisKey; if (SelectedViewStyle == ViewStyle.Regular) { scanSeries1.Title = scan.TheLJVScan.Pixel.Site; } if (SelectedViewStyle == ViewStyle.Aging) { scanSeries1.Title = scan.TheLJVScan.DeviceLJVScanSummary.TestCondition; } PropertyInfo xprop = SelectedBottomAxisProperty.Item2; PropertyInfo y1prop = SelectedLeftAxisProperty.Item2; PropertyInfo y2prop = SelectedRightAxisProperty.Item2; foreach (ProcessedLJVDatum pd in scan.ProcLJVDataList) { double xval = Convert.ToDouble((decimal)xprop.GetValue(pd)); double y1val = Convert.ToDouble((decimal)y1prop.GetValue(pd)); double y2val = Convert.ToDouble((decimal)y2prop.GetValue(pd)); scanSeries1.Points.Add(new DataPoint(xval, y1val)); scanSeries2.Points.Add(new DataPoint(xval, y2val)); } ThePlotModel.Series.Add(scanSeries1); ThePlotModel.Series.Add(scanSeries2); } } } ThePlotModel.InvalidatePlot(true);//do this out of superstition/ignorance }