protected void PostProcess(PlotModel model, IList <ISeriesInfo> siList, string outFile, int outWidth, int outHeight, bool svgIsDocument, bool passThru, Style style, bool asPlotView, bool show, bool reuseWindow) { var bp = MyInvocation.BoundParameters; var si = siList != null && siList.Count > 0 ? siList[0] : null; // When Ax/Ay parameters are specified, creates axis objects. Axis xAxis = null; Axis yAxis = null; Axis zAxis = null; if (si?.Series?.Count > 0) { xAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Ax, si.Series[0], si, style); yAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Ay, si.Series[0], si, style); zAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Az, si.Series[0], si, style); } // Creates a model if necessary. if (model == null && (!string.IsNullOrEmpty(outFile) || xAxis != null || yAxis != null || zAxis != null || asPlotView || show)) { model = PlotModelInitializer.Create(siList, style); } // Returns a SeriesInfo object when a model object is not necessary. if (model == null) { WriteObject(si); return; } // Adds series and axes to a model. if (xAxis != null) { model.Axes.Add(xAxis); } if (yAxis != null) { model.Axes.Add(yAxis); } if (zAxis != null) { model.Axes.Add(zAxis); } foreach (var si2 in siList) { foreach (var s in si2.Series) { model.Series.Add(s); /* * if (s is XYAxisSeries xy) * { * if (xAxis != null) * xy.XAxisKey = xAxis.Key; * * if (yAxis != null) * xy.YAxisKey = yAxis.Key; * } */ if (s is CandleStickAndVolumeSeries candlev) { if (zAxis != null) { candlev.VolumeAxisKey = zAxis.Key; } } else if (s is HeatMapSeries h) { if (zAxis != null) { h.ColorAxisKey = zAxis.Key; } } else if (s is RectangleSeries r) { if (zAxis != null) { r.ColorAxisKey = zAxis.Key; } } } } // Export a model. if (bp.ContainsKey("OutFile")) { ModelExporter.Export(model, outFile, outWidth, outHeight, svgIsDocument); } // Show a model in the window; if (show) { var window = CreateWindow(reuseWindow); window.Dispatcher.Invoke(() => { window.Content = new OxyPlot.Wpf.PlotView() { Model = model }; if (!reuseWindow && string.IsNullOrEmpty(window.Title)) { window.Title = MyInvocation.Line; } }); } // Return a model. if (asPlotView) { OxyPlot.Wpf.PlotView e = null; PlotViewDispatcherHolder.Get().Invoke(() => { e = new OxyPlot.Wpf.PlotView() { Model = model }; }); WriteObject(e); } else { if (passThru || (!bp.ContainsKey("OutFile") && !show)) { WriteObject(model); } } }
protected override void BeginProcessing() { WriteObject(PlotViewDispatcherHolder.Get()); }