コード例 #1
0
        private void PopularDadosGrafico()
        {
            ViewType[] ignorarOsTipos = new ViewType[]
            {
                ViewType.PolarArea,
                ViewType.PolarLine,
                ViewType.PolarPoint,
                //ViewType.SideBySideGantt,
                ViewType.SideBySideRangeBar,
                ViewType.RangeBar,
                //ViewType.Gantt,
                ViewType.Stock,
                ViewType.SwiftPlot,
                ViewType.CandleStick,
                //ViewType.SideBySideFullStackedBar,
                //ViewType.SideBySideFullStackedBar3D,
                //ViewType.SideBySideStackedBar,
                //ViewType.SideBySideStackedBar3D
            };

            #region Layout

            Enum.GetValues(typeof(ViewType))
            .OfType <ViewType>()
            .Where(w => !ignorarOsTipos.Contains(w))
            .ToList()
            .ForEach(f =>
            {
                BarCheckItem barCheckItem = new BarCheckItem();
                barCheckItem.Caption      = f.ToString();
                barCheckItem.Tag          = f;

                barCheckItem.ItemClick += delegate(object senderItemClick, ItemClickEventArgs eItemClick)
                {
                    if ((eItemClick.Item as BarCheckItem).Checked)
                    {
                        // Procura e desmarca o item selecionado
                        this.brMngrCustomGrid.Items
                        .OfType <BarCheckItem>()
                        .Where(w => w.Tag != null && w.Tag is ViewType && eItemClick.Item != w && w.Checked)
                        .Update(u => u.Checked = false);

                        this.chtCtrlVisualizacoes.SeriesTemplate.ChangeView((ViewType)eItemClick.Item.Tag);

                        this.chtCtrlVisualizacoes.Legend.Visible = this.brChckItmLegenda.Checked;
                        this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideDataByColumns     = this.brChckItmAlterarLinhasPorColunas.Checked;
                        this.pvtGrdVisualizacoes.OptionsChartDataSource.SelectionOnly            = this.brChckItmSomenteOSelecionado.Checked;
                        this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideColumnGrandTotals = this.brChckItmMostrarTotalColuna.Checked;
                        this.pvtGrdVisualizacoes.OptionsChartDataSource.ProvideRowGrandTotals    = this.brChckItmMostrarTotalLinha.Checked;
                        this.chtCtrlVisualizacoes.Legend.Visible = this.brChckItmLegenda.Checked;
                        if (this.chtCtrlVisualizacoes.SeriesTemplate.Label != null)
                        {
                            this.chtCtrlVisualizacoes.SeriesTemplate.Label.Visible = this.brChckItmValor.Checked;
                        }

                        if (this.Diagram3D != null)
                        {
                            this.Diagram3D.RuntimeRotation  = true;
                            this.Diagram3D.RuntimeZooming   = true;
                            this.Diagram3D.RuntimeScrolling = true;
                        }
                        else
                        if (this.XyDiagram != null)
                        {
                            this.XyDiagram.AxisX.Visible                  = this.brChckItmEixoX.Checked;
                            this.XyDiagram.AxisX.Title.Visible            = true;
                            this.XyDiagram.AxisX.Range.MaxValue           = 20;
                            this.XyDiagram.AxisX.Range.Auto               = true;
                            this.XyDiagram.AxisX.Range.SideMarginsEnabled = true;

                            this.XyDiagram.AxisY.Visible                  = this.brChckItmEixoY.Checked;
                            this.XyDiagram.AxisY.Title.Visible            = true;
                            this.XyDiagram.AxisY.Range.MaxValue           = 20;
                            this.XyDiagram.AxisY.Range.Auto               = true;
                            this.XyDiagram.AxisY.Range.SideMarginsEnabled = true;

                            this.XyDiagram.Rotated = this.brChckItmVirar.Checked;
                            this.XyDiagram.DefaultPane.EnableAxisXScrolling = DevExpress.Utils.DefaultBoolean.True;
                        }


                        this.chtCtrlVisualizacoes.Series
                        .OfType <Series>()
                        .ToList()
                        .ForEach(f1 =>
                        {
                            ISupportTransparency supportTransparency = f1.View as ISupportTransparency;
                            if (supportTransparency != null &&
                                (f1.View is AreaSeriesView ||
                                 f1.View is Area3DSeriesView ||
                                 f1.View is RadarAreaSeriesView ||
                                 f1.View is Bar3DSeriesView))
                            {
                                supportTransparency.Transparency = 135;
                            }
                        });

                        Series series = this.chtCtrlVisualizacoes.Series
                                        .OfType <Series>()
                                        .FirstOrDefault();

                        if (series != null && series.View != null)
                        {
                            this.brSbItmTipo.Enabled = series.View is PointSeriesView;
                            this.brMngrCustomGrid.Items
                            .OfType <BarCheckItem>()
                            .Where(w => w.Checked)
                            .FirstOrDefault()
                            .PerformClick();
                        }
                    }
                    else
                    {
                        (eItemClick.Item as BarCheckItem).Checked = true;
                    }
                };

                if (f.ToString().ToUpper().IndexOf("RADAR") != -1)
                {
                    this.brSbItmRadar.AddItem(barCheckItem);
                }
                else
                if (f.ToString().ToUpper().IndexOf("BAR") != -1)
                {
                    this.brSbItmBarra.AddItem(barCheckItem);
                }
                else
                if (f.ToString().ToUpper().IndexOf("LINE") != -1)
                {
                    this.brSbItmLinha.AddItem(barCheckItem);
                }
                else
                if (f.ToString().ToUpper().IndexOf("AREA") != -1)
                {
                    this.brSbItmArea.AddItem(barCheckItem);
                }
                else
                if (f.ToString().ToUpper().IndexOf("PIE") != -1 || f.ToString().ToUpper().IndexOf("DOUGHNUT") != -1)
                {
                    this.brSbItmPizza.AddItem(barCheckItem);
                }
                else
                {
                    this.brSbItmOutros.AddItem(barCheckItem);
                }
            });

            #endregion

            #region Tipo

            Enum.GetValues(typeof(MarkerKind))
            .OfType <MarkerKind>()
            .ToList()
            .ForEach(u =>
            {
                BarCheckItem barCheckItem = new BarCheckItem();
                barCheckItem.Caption      = u.ToString();
                barCheckItem.Tag          = u;

                barCheckItem.ItemClick += delegate(object senderItemClick, ItemClickEventArgs eItemClick)
                {
                    if ((eItemClick.Item as BarCheckItem).Checked)
                    {
                        // Procura e desmarca o item selecionado
                        this.brSbItmTipo.LinksPersistInfo
                        .OfType <LinkPersistInfo>()
                        .Where(w => eItemClick.Item != w.Item && (w.Item as BarCheckItem).Checked)
                        .Update(u1 => (u1.Item as BarCheckItem).Checked = false);

                        // Altera o Kind de todas series
                        MarkerKind markerKind = (MarkerKind)eItemClick.Item.Tag;
                        this.chtCtrlVisualizacoes.Series
                        .OfType <Series>()
                        .ToList()
                        .ForEach(f1 =>
                        {
                            PointSeriesView pointSeriesView = f1.View as PointSeriesView;
                            if (pointSeriesView != null)
                            {
                                pointSeriesView.PointMarkerOptions.Kind          = markerKind;
                                pointSeriesView.PointMarkerOptions.BorderVisible = false;
                            }
                        });
                    }
                    else
                    {
                        (eItemClick.Item as BarCheckItem).Checked = true;
                    }
                };
                this.brSbItmTipo.AddItem(barCheckItem);
            });

            #endregion

            this.chtCtrlVisualizacoes.DataSource = this.pvtGrdVisualizacoes;
            this.chtCtrlVisualizacoes.RefreshData();

            this.brMngrCustomGrid.Items
            .OfType <BarCheckItem>()
            .Where(w => w.Tag != null && w.Tag.Equals(ViewType.Line))
            .FirstOrDefault()
            .PerformClick();

            this.brMngrCustomGrid.Items
            .OfType <BarCheckItem>()
            .Where(w => w.Tag != null && w.Tag.Equals(MarkerKind.Circle))
            .FirstOrDefault()
            .PerformClick();
        }