Example #1
0
        UIElement[] IView2DRenderer.Generate()
        {
            int nser = _dataInfo.nser;
            int npts = _dataInfo.npts;

            if ((nser == 0) || (npts == 0))
            {
                return(null);
            }
            IPlotElement element = null;

            if (base.Symbol is PlotElement)
            {
                element = ((PlotElement)base.Symbol).Clone() as IPlotElement;
            }
            List <UIElement> objects = new List <UIElement>();

            for (int i = 0; i < nser; i++)
            {
                DataSeries ds = (DataSeries)base.Series[i];
                ds.Children.Clear();
                objects.Add(ds);
                if (ds.SymbolShape == null)
                {
                    ds.SymbolShape = base.StyleGen.Next();
                }
                ShapeStyle symbolShape = ds.SymbolShape;
                double[,] values = ds.GetValues();
                if (values != null)
                {
                    int           length = values.GetLength(1);
                    int           num5   = values.GetLength(0);
                    RenderContext rc     = new RenderContext(this, ds, length)
                    {
                        Bounds = CoordConverter.ViewBounds
                    };
                    for (int j = 0; j < length; j++)
                    {
                        if (base.ColorScheme == ColorScheme.Point)
                        {
                            symbolShape = base.StyleGen.GetStyle(j);
                        }
                        double       y     = values[0, j];
                        double       x     = (num5 >= 2) ? values[1, j] : ((double)j);
                        bool         flag  = false;
                        Style        style = base.GetStyle(ds, i, j);
                        IPlotElement pe    = base.CreateElement(ds.Symbol, style);
                        if (pe == null)
                        {
                            pe = PlotElement.SymbolFromMarker(ds.SymbolMarker);
                            if ((pe != null) && (style != null))
                            {
                                pe.Style = style;
                            }
                        }
                        if ((pe == null) && ds.ChartType.HasValue)
                        {
                            ChartSubtype subtype = ChartTypes.GetSubtype(ds.ChartType.ToString());
                            if (subtype != null)
                            {
                                pe = base.CreateElement(subtype.Symbol, style);
                            }
                        }
                        else if (((pe == null) && ds.IsDefaultSymbol) && (element != null))
                        {
                            pe       = element;
                            pe.Style = style;
                            element  = ((PlotElement)base.Symbol).Clone() as IPlotElement;
                        }
                        if ((pe == null) && ((ds.PointLabelTemplate != null) || (ds.PointTooltipTemplate != null)))
                        {
                            DotSymbol symbol = new DotSymbol();
                            symbol.Fill   = TransparentBrush;
                            symbol.Size   = new Size(5.0, 5.0);
                            symbol.Stroke = TransparentBrush;
                            pe            = symbol;
                            flag          = true;
                        }
                        Point point   = CoordConverter.ConvertPoint(new Point(x, y));
                        Axis  auxAxis = GetAuxAxis(j);
                        if (auxAxis != null)
                        {
                            ChartViewport2D coordConverter = CoordConverter as ChartViewport2D;
                            if (coordConverter != null)
                            {
                                point = coordConverter.ConvertPoint(new Point(x, y), base.Chart.View.AxisX, auxAxis);
                            }
                        }
                        rc.SetPoint(j, point.X, point.Y);
                        if (!double.IsNaN(point.X) && !double.IsNaN(point.Y))
                        {
                            DataPoint dp       = ds.CreateDataPoint(i, j);
                            UIElement element3 = base.RenderElement(objects, pe, ds, rc, symbolShape, dp);
                            if ((element3 != null) && flag)
                            {
                                Canvas.SetZIndex(element3, 2);
                            }
                        }
                    }
                    PlotElement element4 = base.RenderConnection(ds, rc, i);
                    if (element4 != null)
                    {
                        element4.DataPoint = ds.CreateDataPoint(i, -1);
                        ds.Children.Insert(0, element4);
                    }
                }
            }
            return(objects.ToArray());
        }
Example #2
0
        protected override bool Render(RenderContext rc)
        {
            Point[] points = rc.Points;
            if (points == null)
            {
                return(false);
            }
            Rect clipBounds = rc.ClipBounds;

            if (_xinc)
            {
                points = ClipPoints(rc.Bounds, points);
            }
            clipBounds = Utils.InflateRect(clipBounds, base.StrokeThickness, base.StrokeThickness);
            bool   isCustomClipping = rc.IsCustomClipping;
            double naN = double.NaN;

            if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Lines) > ((OptimizationRadiusScope)0))
            {
                naN = rc.OptimizationRadius;
            }

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();

            if (rc.hasNan)
            {
                List <Point[]> list = SplitPointsWithHoles(points);
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        PathFigure[] figureArray = RenderSegment(list[i], naN, isCustomClipping ? clipBounds : Extensions.EmptyRect);
                        int          length      = figureArray.Length;
                        for (int j = 0; j < length; j++)
                        {
                            geometry.Figures.Add(figureArray[j]);
                        }
                    }
                }
            }
            else
            {
                PathFigure[] figureArray2 = RenderSegment(points, naN, isCustomClipping ? clipBounds : Extensions.EmptyRect);
                if (figureArray2 != null)
                {
                    int num5 = figureArray2.Length;
                    for (int k = 0; k < num5; k++)
                    {
                        geometry.Figures.Add(figureArray2[k]);
                    }
                }
            }
            Data       = geometry;
            _labelRect = clipBounds;

            if (!isCustomClipping)
            {
                RectangleGeometry geometry2 = new RectangleGeometry();
                geometry2.Rect = clipBounds;
                base.Clip      = geometry2;
            }
            return(true);
        }