Пример #1
0
        public ChartView(Chart p_chart)
        {
            _chart     = p_chart;
            _axes.View = this;
            AxisX      = new Axis();
            AxisY      = new Axis();
            AxisX.SetFixedType(AxisType.X);
            AxisY.SetFixedType(AxisType.Y);
            _axes.Add(AxisX);
            _axes.Add(AxisY);

            _viewport = new ChartViewport2D(this);

            _plotShape      = new Rectangle();
            _plotShape.Fill = new SolidColorBrush(Colors.Transparent);

            _areas = new PlotAreaCollection();
            _areas.CollectionChanged += _areas_CollectionChanged;

            _layers = new ObservableCollection <IChartLayer>();
            _layers.CollectionChanged += _layers_CollectionChanged;
        }
Пример #2
0
        internal RenderContext(IRenderer renderer, IDataSeriesInfo ds, int npts)
        {
            _cur          = new Point();
            _prev         = new Point();
            _curView      = new Point();
            _bounds       = new Rect();
            _stacked      = new List <double>();
            _excludeHoles = true;
            _pts          = new List <Point>();
            _rect         = Extensions.EmptyRect;
            _clipBounds   = Extensions.EmptyRect;
            _rendrerer    = renderer;
            _ds           = ds;
            _pts.Capacity = npts;
            if (_ds != null)
            {
                _names = _ds.GetDataNames();
            }
            Chart visual = renderer.Visual as Chart;

            Chart = visual;
            BaseRenderer renderer2 = renderer as BaseRenderer;

            _isStacked = (renderer2 != null) && renderer2.IsStacked;
            hasNan     = renderer2._dataInfo.hasNaN;
            DataSeries series = ds as DataSeries;

            if (series != null)
            {
                Renderer2D rendererd = renderer as Renderer2D;
                if ((((byte)(series.Display & SeriesDisplay.ShowNaNGap)) != 0) && (rendererd != null))
                {
                    _excludeHoles = false;
                }
                if (rendererd != null)
                {
                    string axisX = series.AxisX;
                    string axisY = series.AxisY;
                    bool   flag  = !string.IsNullOrEmpty(axisX);
                    bool   flag2 = !string.IsNullOrEmpty(axisY);
                    if (visual != null)
                    {
                        ChartViewport2D viewElement = visual.View.Viewport;
                        if (viewElement != null)
                        {
                            if (flag || flag2)
                            {
                                foreach (Axis axis in viewElement.Axes)
                                {
                                    if (flag && (axis.AxisName == axisX))
                                    {
                                        _ax    = axis;
                                        hasNan = true;
                                    }
                                    if (flag2 && (axis.AxisName == axisY))
                                    {
                                        _ay    = axis;
                                        hasNan = true;
                                    }
                                }
                            }
                            _defax = viewElement._ax;
                            _defay = viewElement._ay;
                        }
                    }
                }
            }
            if (visual.View != null)
            {
                ChartView view = visual.View;
                if (_ax != null)
                {
                    XReversed = _ax.ReversedInternal;
                }
                else if (visual.View.AxisX != null)
                {
                    XReversed = visual.View.AxisX.Reversed;
                }
                if (_ay != null)
                {
                    YReversed = _ay.ReversedInternal;
                }
                else if (visual.View.AxisY != null)
                {
                    YReversed = visual.View.AxisY.Reversed;
                }
                Axis axis2 = visual.View.GetAxisX(series);
                if ((axis2 != null) && !double.IsNaN(axis2.LogBase))
                {
                    hasNan = true;
                }
                Axis axis3 = visual.View.GetAxisY(series);
                if ((axis3 != null) && !double.IsNaN(axis3.LogBase))
                {
                    hasNan = true;
                }
                if ((renderer2 != null) && renderer2.Inverted)
                {
                    if ((axis2 != null) && (axis2.PlotAreaIndex != 0))
                    {
                        ClusterPlotAreaIndex = axis2.PlotAreaIndex;
                    }
                }
                else if ((axis3 != null) && (axis3.PlotAreaIndex != 0))
                {
                    ClusterPlotAreaIndex = axis3.PlotAreaIndex;
                }
            }
        }
Пример #3
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());
        }