Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void EndProcessing()
        {
            var bp    = MyInvocation.BoundParameters;
            var style = TypeAdaptors.Style.ConvertFrom(Style);

            var model = _plotModel ?? new PlotModel();

            PlotModelInitializer.Create(model, _seriesInfoList, style);

            foreach (var s in _seriesList)
            {
                model.Series.Add(s);
            }

            foreach (var a in Axis)
            {
                model.Axes.Add(a);
            }

            foreach (var a in Annotation)
            {
                model.Annotations.Add(a);
            }

            if (bp.ContainsKey("DefaultFont"))
            {
                model.DefaultFont = DefaultFont;
            }
            if (bp.ContainsKey("DefaultFontSize"))
            {
                model.DefaultFontSize = DefaultFontSize;
            }
            if (bp.ContainsKey("Background"))
            {
                model.Background = Background;
            }
            if (bp.ContainsKey("Culture"))
            {
                model.Culture = Culture;
            }
            if (bp.ContainsKey("DefaultColors"))
            {
                model.DefaultColors = DefaultColors;
            }
            if (bp.ContainsKey("IsLegendVisible"))
            {
                model.IsLegendVisible = IsLegendVisible;
            }
            if (bp.ContainsKey("LegendBackground"))
            {
                model.LegendBackground = LegendBackground;
            }
            if (bp.ContainsKey("LegendBorder"))
            {
                model.LegendBorder = LegendBorder;
            }
            if (bp.ContainsKey("LegendBorderThickness"))
            {
                model.LegendBorderThickness = LegendBorderThickness;
            }
            if (bp.ContainsKey("LegendColumnSpacing"))
            {
                model.LegendColumnSpacing = LegendColumnSpacing;
            }
            if (bp.ContainsKey("LegendFont"))
            {
                model.LegendFont = LegendFont;
            }
            if (bp.ContainsKey("LegendFontSize"))
            {
                model.LegendFontSize = LegendFontSize;
            }
            if (bp.ContainsKey("LegendTextColor"))
            {
                model.LegendTextColor = LegendTextColor;
            }
            if (bp.ContainsKey("LegendFontWeight"))
            {
                model.LegendFontWeight = LegendFontWeight;
            }
            if (bp.ContainsKey("LegendItemAlignment"))
            {
                model.LegendItemAlignment = LegendItemAlignment;
            }
            if (bp.ContainsKey("LegendItemOrder"))
            {
                model.LegendItemOrder = LegendItemOrder;
            }
            if (bp.ContainsKey("LegendItemSpacing"))
            {
                model.LegendItemSpacing = LegendItemSpacing;
            }
            if (bp.ContainsKey("LegendLineSpacing"))
            {
                model.LegendLineSpacing = LegendLineSpacing;
            }
            if (bp.ContainsKey("LegendMargin"))
            {
                model.LegendMargin = LegendMargin;
            }
            if (bp.ContainsKey("LegendMaxWidth"))
            {
                model.LegendMaxWidth = LegendMaxWidth;
            }
            if (bp.ContainsKey("LegendMaxHeight"))
            {
                model.LegendMaxHeight = LegendMaxHeight;
            }
            if (bp.ContainsKey("LegendOrientation"))
            {
                model.LegendOrientation = LegendOrientation;
            }
            if (bp.ContainsKey("LegendPadding"))
            {
                model.LegendPadding = LegendPadding;
            }
            if (bp.ContainsKey("LegendPlacement"))
            {
                model.LegendPlacement = LegendPlacement;
            }
            if (bp.ContainsKey("LegendPosition"))
            {
                model.LegendPosition = LegendPosition;
            }
            if (bp.ContainsKey("LegendSymbolLength"))
            {
                model.LegendSymbolLength = LegendSymbolLength;
            }
            if (bp.ContainsKey("LegendSymbolMargin"))
            {
                model.LegendSymbolMargin = LegendSymbolMargin;
            }
            if (bp.ContainsKey("LegendSymbolPlacement"))
            {
                model.LegendSymbolPlacement = LegendSymbolPlacement;
            }
            if (bp.ContainsKey("LegendTitle"))
            {
                model.LegendTitle = LegendTitle;
            }
            if (bp.ContainsKey("LegendTitleColor"))
            {
                model.LegendTitleColor = LegendTitleColor;
            }
            if (bp.ContainsKey("LegendTitleFont"))
            {
                model.LegendTitleFont = LegendTitleFont;
            }
            if (bp.ContainsKey("LegendTitleFontSize"))
            {
                model.LegendTitleFontSize = LegendTitleFontSize;
            }
            if (bp.ContainsKey("LegendTitleFontWeight"))
            {
                model.LegendTitleFontWeight = LegendTitleFontWeight;
            }
            if (bp.ContainsKey("Padding"))
            {
                model.Padding = new Horker.OxyPlotCli.TypeAdaptors.OxyThickness(Padding);
            }
            if (bp.ContainsKey("AxisTierDistance"))
            {
                model.AxisTierDistance = AxisTierDistance;
            }
            if (bp.ContainsKey("PlotAreaBackground"))
            {
                model.PlotAreaBackground = PlotAreaBackground;
            }
            if (bp.ContainsKey("PlotAreaBorderColor"))
            {
                model.PlotAreaBorderColor = PlotAreaBorderColor;
            }
            if (bp.ContainsKey("PlotAreaBorderThickness"))
            {
                model.PlotAreaBorderThickness = new Horker.OxyPlotCli.TypeAdaptors.OxyThickness(PlotAreaBorderThickness);
            }
            if (bp.ContainsKey("PlotMargins"))
            {
                model.PlotMargins = new Horker.OxyPlotCli.TypeAdaptors.OxyThickness(PlotMargins);
            }
            if (bp.ContainsKey("PlotType"))
            {
                model.PlotType = PlotType;
            }
            if (bp.ContainsKey("RenderingDecorator"))
            {
                model.RenderingDecorator = RenderingDecorator;
            }
            if (bp.ContainsKey("Subtitle"))
            {
                model.Subtitle = Subtitle;
            }
            if (bp.ContainsKey("SubtitleFont"))
            {
                model.SubtitleFont = SubtitleFont;
            }
            if (bp.ContainsKey("SubtitleFontSize"))
            {
                model.SubtitleFontSize = SubtitleFontSize;
            }
            if (bp.ContainsKey("SubtitleFontWeight"))
            {
                model.SubtitleFontWeight = SubtitleFontWeight;
            }
            if (bp.ContainsKey("TextColor"))
            {
                model.TextColor = TextColor;
            }
            if (bp.ContainsKey("Title"))
            {
                model.Title = Title;
            }
            if (bp.ContainsKey("TitleToolTip"))
            {
                model.TitleToolTip = TitleToolTip;
            }
            if (bp.ContainsKey("TitleColor"))
            {
                model.TitleColor = TitleColor;
            }
            if (bp.ContainsKey("SubtitleColor"))
            {
                model.SubtitleColor = SubtitleColor;
            }
            if (bp.ContainsKey("TitleHorizontalAlignment"))
            {
                model.TitleHorizontalAlignment = TitleHorizontalAlignment;
            }
            if (bp.ContainsKey("TitleFont"))
            {
                model.TitleFont = TitleFont;
            }
            if (bp.ContainsKey("TitleFontSize"))
            {
                model.TitleFontSize = TitleFontSize;
            }
            if (bp.ContainsKey("TitleFontWeight"))
            {
                model.TitleFontWeight = TitleFontWeight;
            }
            if (bp.ContainsKey("TitlePadding"))
            {
                model.TitlePadding = TitlePadding;
            }
            if (bp.ContainsKey("SelectionColor"))
            {
                model.SelectionColor = SelectionColor;
            }

            PostProcess(model, _seriesInfoList, OutFile, OutWidth, OutHeight, SvgIsDocument, PassThru, style, AsPlotView, Show, ReuseWindow);
        }