/// <summary> /// 챠트 타입이 변경되었을경우 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboChartType_SelectedIndexChanged(object sender, EventArgs e) { try { chartControl1.SeriesTemplate.ChangeView((ViewType)comboChartType.SelectedItem); if (chartControl1.Diagram is Diagram3D) { Diagram3D diagram = (Diagram3D)chartControl1.Diagram; diagram.RuntimeRotation = true; diagram.RuntimeZooming = true; diagram.RuntimeScrolling = true; } foreach (Series series in chartControl1.Series) { ISupportTransparency supportTransparency = series.View as ISupportTransparency; if (supportTransparency != null) { if ((series.View is AreaSeriesView) || (series.View is Area3DSeriesView)) { supportTransparency.Transparency = 135; } else { supportTransparency.Transparency = 0; } } } } catch (Exception ex) { Basic.ShowMessage(1, ex.Message); } }
public static Series CreateSeriesInstance(Type seriesType) { Series series = (Series)Activator.CreateInstance(seriesType); ISupportTransparency supportTransparency = series as ISupportTransparency; if (supportTransparency != null) { bool flag = series is AreaSeries2D; flag = flag || series is AreaSeries3D; if (flag) { supportTransparency.Transparency = 0.4; } else { supportTransparency.Transparency = 0; } } return(series); }
void UpdateSeries() { SeriesTypeItem seriesTypeItem = cbSeriesTypes.SelectedItem as SeriesTypeItem; if (seriesTypeItem != null) { chart.BeginInit(); try { chart.Diagram = (Diagram)Activator.CreateInstance(seriesTypeItem.DiagramType); for (int i = 0; i < seriesTypeItem.SeriesCount; i++) { Series series = (Series)Activator.CreateInstance(seriesTypeItem.SeriesType); if (loading) { series.AnimationAutoStartMode = AnimationAutoStartMode.SetStartState; } series.Label = new SeriesLabel(); UpdateSeries(series, i); ISupportStackedGroup supportStackedGroup = series as ISupportStackedGroup; if (supportStackedGroup != null) { supportStackedGroup.StackedGroup = i % 2; } ISupportTransparency supportTransparency = series as ISupportTransparency; if (supportTransparency != null) { supportTransparency.Transparency = 0.3; } series.LabelsVisibility = true; series.Label.ResolveOverlappingMode = ResolveOverlappingMode.Default; chart.Diagram.Series.Add(series); } } finally { chart.EndInit(); } } }
void comboBoxEdit2_SelectedIndexChanged(object sender, EventArgs e) { ChartCntrol.SeriesTemplate.ChangeView((ViewType)comboChartType.SelectedItem); if (ChartCntrol.SeriesTemplate.Label != null) { ChartCntrol.SeriesTemplate.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;// = checkShowPointLabels.Checked; checkShowPointLabels.Enabled = true; } else { checkShowPointLabels.Enabled = false; } if ((ChartCntrol.SeriesTemplate.View as SimpleDiagramSeriesViewBase) == null) { ChartCntrol.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True; } if (ChartCntrol.Diagram is Diagram3D) { Diagram3D diagram = (Diagram3D)ChartCntrol.Diagram; diagram.RuntimeRotation = true; diagram.RuntimeZooming = true; diagram.RuntimeScrolling = true; } foreach (Series series in ChartCntrol.Series) { ISupportTransparency supportTransparency = series.View as ISupportTransparency; if (supportTransparency != null) { if ((series.View is AreaSeriesView) || (series.View is Area3DSeriesView) || (series.View is RadarAreaSeriesView) || (series.View is Bar3DSeriesView)) { supportTransparency.Transparency = 135; } else { supportTransparency.Transparency = 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(); }
void ChangeDiagram(SeriesTypeItem item) { if (item == null) { return; } chart.Diagram = (Diagram)Activator.CreateInstance(item.DiagramType); bool isAreaFullStackedSeries = false; Axis axisX = null, axisY = null; XYDiagram2D diagram2D = chart.Diagram as XYDiagram2D; if (diagram2D != null) { chart.Legend.HorizontalPosition = HorizontalPosition.RightOutside; diagram2D.AxisX = new AxisX2D(); diagram2D.AxisY = new AxisY2D(); axisX = diagram2D.AxisX; axisY = diagram2D.AxisY; isAreaFullStackedSeries = item.SeriesType == typeof(AreaFullStackedSeries2D); } else { chart.Legend.HorizontalPosition = HorizontalPosition.Right; XYDiagram3D diagram3D = chart.Diagram as XYDiagram3D; if (diagram3D != null) { diagram3D.AxisX = new AxisX3D(); diagram3D.AxisY = new AxisY3D(); axisX = diagram3D.AxisX; axisY = diagram3D.AxisY; diagram3D.SeriesPadding = 0.5; diagram3D.SeriesDistance = 1.5; isAreaFullStackedSeries = item.SeriesType == typeof(AreaFullStackedSeries3D); } } if (axisX != null) { axisX.Label = new AxisLabel() { TextPattern = "{A:m}" }; } if (axisY != null) { if (isAreaFullStackedSeries) { axisY.Label = new AxisLabel() { TextPattern = "{VP:P0}" } } ; else { axisY.Title = new AxisTitle(); axisY.Title.Content = "Number of visitors"; } } Series politicsSeries = (Series)Activator.CreateInstance(item.SeriesType); politicsSeries.DisplayName = "Politics"; politicsSeries.ValueDataMember = "Politics"; PrepareSeriesAnimation(politicsSeries, 0); Series entertainmentSeries = (Series)Activator.CreateInstance(item.SeriesType); entertainmentSeries.DisplayName = "Entertainment"; entertainmentSeries.ValueDataMember = "Entertainment"; PrepareSeriesAnimation(entertainmentSeries, 1); Series travelSeries = (Series)Activator.CreateInstance(item.SeriesType); travelSeries.DisplayName = "Travel"; travelSeries.ValueDataMember = "Travel"; PrepareSeriesAnimation(travelSeries, 2); chart.Diagram.Series.AddRange(new Series[] { politicsSeries, entertainmentSeries, travelSeries }); foreach (Series series in chart.Diagram.Series) { ISupportTransparency supportTransparency = series as ISupportTransparency; if (supportTransparency != null) { supportTransparency.Transparency = 0.5; } series.Label = new SeriesLabel(); if (isAreaFullStackedSeries) { series.Label.TextPattern = "{VP:P0}"; } series.LabelsVisibility = cheLabelsVisible.IsChecked.Value; series.Label.ResolveOverlappingMode = ResolveOverlappingMode.Default; series.ArgumentScaleType = ScaleType.DateTime; series.ArgumentDataMember = "Date"; series.DataSource = dataSource; } }