コード例 #1
0
        UIElement[] IView2DRenderer.Generate()
        {
            int nser = _dataInfo.nser;
            int npts = _dataInfo.npts;

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

            List <UIElement> objects    = new List <UIElement>();
            Rect             dataBounds = CoordConverter.DataBounds;
            bool             isStacked  = base.IsStacked;
            StackedSum       sum        = null;
            StackedSum       sum2       = null;
            StackedSum       sum3       = null;
            int nsg = 1;

            if (isStacked)
            {
                nsg  = base.NStackGroups();
                sum  = new StackedSum(nsg);
                sum2 = new StackedSum(nsg);
                sum3 = new StackedSum(nsg);
            }

            double       num4  = GetClusterWidth() * _dataInfo.DeltaX;
            IPlotElement defel = null;

            if (base.Symbol is PlotElement)
            {
                defel = ((PlotElement)base.Symbol).Clone() as IPlotElement;
            }

            bool defval   = (defel != null) ? defel.IsClustered : false;
            bool inverted = base.Inverted;
            int  num5     = 0;

            int[] numArray  = null;
            int[] numArray2 = null;
            if (isStacked)
            {
                num5 = base.NStackGroups();
            }
            else
            {
                numArray  = NClustered(defval);
                numArray2 = new int[numArray.Length];
                num5      = numArray[0];
            }

            double d             = 0.0;
            double origin        = 0.0;
            double seriesOverlap = 0.0;
            Chart  visual        = Chart;
            string xformat       = null;
            string yformat       = null;
            bool   flag4         = false;
            bool   flag5         = false;

            if (visual != null)
            {
                origin        = BarColumnOptions.GetOrigin(visual);
                xformat       = visual.View.AxisX.AnnoFormatInternal;
                yformat       = visual.View.AxisY.AnnoFormatInternal;
                flag4         = !double.IsNaN(visual.View.AxisX.LogBase);
                flag5         = !double.IsNaN(visual.View.AxisY.LogBase);
                seriesOverlap = BarColumnOptions.GetSeriesOverlap(visual);
                if (seriesOverlap > 1.0)
                {
                    seriesOverlap = 1.0;
                }
                else if (seriesOverlap < -1.0)
                {
                    seriesOverlap = -1.0;
                }
            }

            int si    = 0;
            int num10 = 0;

            while (si < nser)
            {
                IDataSeriesInfo ds     = base.Series[si];
                DataSeries      series = (DataSeries)base.Series[si];
                series.Children.Clear();
                objects.Add(series);
                series.SetDefaultFormat(xformat, yformat);
                int stackGroup = 0;
                if (isStacked)
                {
                    stackGroup = BarColumnOptions.GetStackGroup(series);
                }
                if (series.SymbolShape == null)
                {
                    series.SymbolShape = base.StyleGen.Next();
                }
                ShapeStyle symbolShape = series.SymbolShape;
                bool?      nullable    = null;
                double[,] values = ds.GetValues();
                if (values != null)
                {
                    int           length = values.GetLength(1);
                    int           num13  = values.GetLength(0);
                    RenderContext rc     = new RenderContext(this, ds, length)
                    {
                        Bounds = CoordConverter.ViewBounds
                    };
                    Rect clipBounds = rc.ClipBounds;
                    clipBounds = new Rect(clipBounds.X - 1.0, clipBounds.Y - 1.0, clipBounds.Width + 2.0, clipBounds.Height + 2.0);
                    double naN = double.NaN;
                    if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Symbols) > ((OptimizationRadiusScope)0))
                    {
                        naN = rc.OptimizationRadius;
                    }
                    bool isClustered = defval;
                    bool flag7       = series.IsStacked;
                    int  num15       = 0;
                    int  num16       = length;
                    if (_dataInfo.incX && !inverted)
                    {
                        Rect rect2 = CoordConverter.DataBounds2D;
                        for (int j = 0; j < length; j++)
                        {
                            double num18 = (num13 >= 2) ? values[1, j] : ((double)j);
                            if (num18 >= rect2.Left)
                            {
                                num15 = Math.Max(0, j - 2);
                                break;
                            }
                        }
                        for (int k = num15; k < length; k++)
                        {
                            double num20 = (num13 >= 2) ? values[1, k] : ((double)k);
                            if (num20 > rect2.Right)
                            {
                                num16 = k;
                                break;
                            }
                        }
                        num16 = Math.Min(length, num16 + 2);
                    }
                    Point point = new Point();
                    for (int i = num15; i < num16; i++)
                    {
                        double       num22     = values[0, i];
                        double       x         = (num13 >= 2) ? values[1, i] : ((double)i);
                        double       y         = x;
                        Style        style     = null;
                        IPlotElement pe        = null;
                        bool?        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (base.ColorScheme == ColorScheme.Point)
                            {
                                symbolShape = base.StyleGen.GetStyle(i);
                            }
                            style = base.GetStyle(series, si, i);
                            pe    = base.CreateElement(series.Symbol, style);
                            if (pe == null)
                            {
                                pe = PlotElement.SymbolFromMarker(series.SymbolMarker);
                                if ((pe != null) && (style != null))
                                {
                                    pe.Style = style;
                                }
                            }
                            if ((pe == null) && series.ChartType.HasValue)
                            {
                                ChartSubtype subtype = ChartTypes.GetSubtype(series.ChartType.ToString());
                                if (subtype != null)
                                {
                                    pe = base.CreateElement(subtype.Symbol, style);
                                }
                            }
                            else if (pe == null)
                            {
                                if (series.IsDefaultSymbol && (defel != null))
                                {
                                    pe       = defel;
                                    pe.Style = style;
                                    defel    = ((PlotElement)base.Symbol).Clone() as IPlotElement;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                            if (pe == null)
                            {
                                isClustered = false;
                                if ((series.PointLabelTemplate != null) || (series.PointTooltipTemplate != null))
                                {
                                    DotSymbol symbol = new DotSymbol();
                                    symbol.Fill   = TransparentBrush;
                                    symbol.Size   = new Size(5.0, 5.0);
                                    symbol.Stroke = TransparentBrush;
                                    pe            = symbol;
                                }
                                else
                                {
                                    nullable = true;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                        }
                        bool flag8 = (flag4 && inverted) || (flag5 && !inverted);
                        if (!flag8)
                        {
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((stackGroup * num4) / ((double)num5));
                                }
                            }
                            else if (isClustered)
                            {
                                int clusterPlotAreaIndex = rc.ClusterPlotAreaIndex;
                                if (clusterPlotAreaIndex == 0)
                                {
                                    if (num5 > 1)
                                    {
                                        x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((num10 * num4) / ((double)num5));
                                    }
                                }
                                else if (numArray[clusterPlotAreaIndex] > 1)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)numArray[clusterPlotAreaIndex]))) + ((numArray2[clusterPlotAreaIndex] * num4) / ((double)numArray[clusterPlotAreaIndex]));
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            if (double.IsNaN(num22))
                            {
                                num22 = 0.0;
                            }
                            if (base.IsStacked100)
                            {
                                if (_dataInfo.Stacked[stackGroup, x] != 0.0)
                                {
                                    num22 = ((num22 * 100.0) / _dataInfo.Stacked[stackGroup, x]) + sum[stackGroup, x];
                                }
                            }
                            else
                            {
                                num22 += sum[stackGroup, x];
                            }
                        }
                        double num26 = x;
                        if (inverted)
                        {
                            double num27 = x;
                            x     = num22;
                            num22 = num27;
                        }
                        double num28 = rc.ConvertX(x);
                        double num29 = rc.ConvertY(num22);
                        if (((isStacked && flag7) && (si > 0)) && ((inverted && !double.IsNaN(num29)) || (!inverted && !double.IsNaN(num28))))
                        {
                            rc.SetPrevious(sum[stackGroup, num26]);
                        }
                        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (isClustered)
                            {
                                int num30 = num5;
                                if (rc.ClusterPlotAreaIndex > 0)
                                {
                                    num30 = numArray[rc.ClusterPlotAreaIndex];
                                }
                                if (num30 > 0)
                                {
                                    if (inverted)
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertY((num4 / ((double)num30)) + num22) - CoordConverter.ConvertY(num22)));
                                    }
                                    else
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertX((num4 / ((double)num30)) + x) - CoordConverter.ConvertX(x)));
                                    }
                                }
                            }
                            else if (inverted)
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertY(num4 + num22) - CoordConverter.ConvertY(num22)));
                            }
                            else
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertX(num4 + x) - CoordConverter.ConvertX(x)));
                            }
                            if (double.IsNaN(d))
                            {
                                d = inverted ? (base.SizeY * 20.0) : (base.SizeX * 20.0);
                            }
                        }
                        if (flag8)
                        {
                            double num31 = 0.0;
                            double num32 = d * num5;
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((stackGroup * num32) / ((double)num5));
                                }
                            }
                            else if ((num5 > 1) && isClustered)
                            {
                                num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((num10 * num32) / ((double)num5));
                            }
                            if (num31 != 0.0)
                            {
                                if (inverted)
                                {
                                    num29 += num31;
                                }
                                else
                                {
                                    num28 += num31;
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            StackedSum sum4;
                            int        num63;
                            double     num64;
                            double     num33 = values[0, i];
                            if (double.IsNaN(num33))
                            {
                                num33 = 0.0;
                            }
                            double num34 = (num33 >= 0.0) ? sum2[stackGroup, num26] : sum3[stackGroup, num26];
                            double num35 = (num33 >= 0.0) ? (sum2[stackGroup, num26] + num33) : (sum3[stackGroup, num26] + num33);
                            if (base.IsStacked100)
                            {
                                num34 = (num34 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                                num35 = (num35 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                            }
                            if (inverted)
                            {
                                double num36;
                                double num37;
                                double num38;
                                if (flag4)
                                {
                                    double minX = rc.GetMinX(CoordConverter.DataBounds2D);
                                    num36 = CoordConverter.ConvertX(Math.Max(num35, minX));
                                    num37 = CoordConverter.ConvertX(Math.Max(num34, minX));
                                }
                                else
                                {
                                    num36 = CoordConverter.ConvertX(num35);
                                    num37 = CoordConverter.ConvertX(num34);
                                }
                                if (flag5)
                                {
                                    num38 = base.SizeY * 20.0;
                                }
                                else
                                {
                                    num38 = Math.Abs((double)(CoordConverter.ConvertY(num4 / ((double)nsg)) - CoordConverter.ConvertY(0.0)));
                                }
                                double width = Math.Abs((double)(num37 - num36));
                                rc.Rect = new Rect(Math.Min(num36, num37), num29 - (0.5 * num38), width, num38);
                                sum[stackGroup, num26] = x;
                            }
                            else
                            {
                                double num41;
                                double num42;
                                double num43;
                                if (flag5)
                                {
                                    double minY = rc.GetMinY(CoordConverter.DataBounds2D);
                                    num41 = CoordConverter.ConvertY(Math.Max(num35, minY));
                                    num42 = CoordConverter.ConvertY(Math.Max(num34, minY));
                                }
                                else
                                {
                                    num41 = CoordConverter.ConvertY(num35);
                                    num42 = CoordConverter.ConvertY(num34);
                                }
                                if (flag4)
                                {
                                    num43 = base.SizeX * 20.0;
                                }
                                else
                                {
                                    num43 = Math.Abs((double)(CoordConverter.ConvertX(num4 / ((double)nsg)) - CoordConverter.ConvertX(0.0)));
                                }
                                double height = Math.Abs((double)(num42 - num41));
                                rc.Rect = new Rect(num28 - (0.5 * num43), Math.Min(num41, num42), num43, height);
                                sum[stackGroup, num26] = num22;
                            }
                            if (num33 >= 0.0)
                            {
                                (sum4 = sum2)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                            else
                            {
                                (sum4 = sum3)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                        }
                        else
                        {
                            nullable2 = nullable;
                            if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                            {
                                double num46 = origin;
                                if (inverted)
                                {
                                    double num47 = rc.GetMinX(CoordConverter.DataBounds2D);
                                    double maxX  = rc.GetMaxX(CoordConverter.DataBounds2D);
                                    if (num46 < num47)
                                    {
                                        num46 = num47;
                                    }
                                    else if (num46 > maxX)
                                    {
                                        num46 = maxX;
                                    }
                                    double num49 = rc.ConvertX(num46);
                                    double num50 = d;
                                    double num51 = Math.Abs((double)(num49 - num28));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num52 = rc.ConvertY(y);
                                        double num53 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num50 = num53 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num50 *= 1.0 + seriesOverlap;
                                        }
                                        double num54 = (num53 - num50) / ((double)(num5 - 1));
                                        rc.Rect = new Rect(Math.Min(num28, num49), (num52 - (0.5 * num53)) + (((num5 - num10) - 1) * num54), num51, num50);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(Math.Min(num28, num49), num29 - (0.5 * num50), num51, num50);
                                    }
                                }
                                else
                                {
                                    double num55 = rc.GetMinY(CoordConverter.DataBounds2D);
                                    double maxY  = rc.GetMaxY(CoordConverter.DataBounds2D);
                                    if (num46 < num55)
                                    {
                                        num46 = num55;
                                    }
                                    else if (num46 > maxY)
                                    {
                                        num46 = maxY;
                                    }
                                    double num57 = rc.ConvertY(num46);
                                    double num58 = d;
                                    double num59 = Math.Abs((double)(num57 - num29));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num60 = rc.ConvertX(y);
                                        double num61 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num58 = num61 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num58 *= 1.0 + seriesOverlap;
                                        }
                                        double num62 = (num61 - num58) / ((double)(num5 - 1));
                                        rc.Rect = new Rect((num60 - (0.5 * num61)) + (num10 * num62), Math.Min(num29, num57), num58, num59);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(num28 - (0.5 * num58), Math.Min(num29, num57), num58, num59);
                                    }
                                }
                            }
                        }
                        rc.SetPoint(i, num28, num29);
                        if (pe != null)
                        {
                            Point point2 = new Point(num28, num29);
                            if ((pe is ICustomClipping) || clipBounds.Contains(point2))
                            {
                                if (double.IsNaN(naN))
                                {
                                    DataPoint dp = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, dp);
                                }
                                else if (((i == 0) || (Math.Abs((double)(point2.X - point.X)) > naN)) || ((Math.Abs((double)(point2.Y - point.Y)) > naN) || (i == (num16 - 1))))
                                {
                                    DataPoint point4 = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, point4);
                                    point = point2;
                                }
                            }
                        }
                    }

                    PlotElement element3 = base.RenderConnection(series, rc, si);
                    if (element3 != null)
                    {
                        series.Children.Insert(0, element3);
                    }

                    if (isClustered)
                    {
                        if (rc.ClusterPlotAreaIndex == 0)
                        {
                            num10++;
                        }
                        else
                        {
                            numArray2[rc.ClusterPlotAreaIndex]++;
                        }
                    }
                }
                si++;
            }
            return(objects.ToArray());
        }
コード例 #2
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());
        }