本文介绍了如何在Devexpress中按Stackbar Chart分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的网页上有一个stackbar devexpress图表控件。我想按月显示数据。现在我想基于数据库显示两个不同大小值的栏。目前我的图表只显示每月一个酒吧。 http://demos.devexpress.com/XTRACHARTSDEMOS/BarViewTypes/BarStackedSideBySideSeries.aspx [ ^ ] 这是我想要的东西实现。但是我的图表每月只显示一个条形图。我将数据动态绑定到图表控件中的系列,这是我的代码。 Hi,i have a stackbar devexpress chart control in my web page. i want to show data count by month. now i want to show two bar for different size value based on database. currently my chart only shows one bar per month. http://demos.devexpress.com/XTRACHARTSDEMOS/BarViewTypes/BarStackedSideBySideSeries.aspx[^]this is something what i want to achieve. but my graph only shows one bar per month. i am binding data dynamic to the series in the chart control, here is my code. <dxchartsui:WebChartControl ID="WebChartControl4" style="box-shadow:3px 3px 3px #999;" runat="server" Height="300px" Width="600px" ClientInstanceName="chart" CrosshairEnabled="False" ToolTipEnabled="False" PaletteName="Nature Colors" SideBySideEqualBarWidth="false"> <legend antialiasing="True"></legend> <%-- <Titles> <dxcharts:ChartTitle Text="Movement Chart" ></dxcharts:ChartTitle> </Titles>--%> <SeriesSerializable> </SeriesSerializable> <DiagramSerializable><dxcharts:XYDiagram><AxisX Title-Text="Month" VisibleInPanesSerializable="-1"><Range SideMarginsEnabled="True" ></Range></AxisX><AxisY Title-Text="Count" Title-Visible="True" VisibleInPanesSerializable="-1" Interlaced="True"><Range SideMarginsEnabled="True"></Range></AxisY></dxcharts:XYDiagram></DiagramSerializable> <BorderOptions Visible="True" /> </dxchartsui:WebChartControl> List<DataTable> dt = CloneTable(objRes.ResultData.Tables[0], 12); WebChartControl4.Series.Clear(); for (int i = 0; i < dt.Count; i++) { Series s = new Series(dt[i].Rows[0][2].ToString(), ViewType.SideBySideStackedBar); DataView dv = dt[i].DefaultView; dv.Sort = "ID ASC"; dt[i] = dv.ToTable(); s.DataSource = dt[i]; s.ArgumentDataMember = dt[i].Columns[0].ColumnName; s.ValueDataMembers.AddRange(new string[] { dt[i].Columns[1].ColumnName }); s.LegendPointOptions.PointView = PointView.Argument; s.ShowInLegend = true; s.LabelsVisibility = DefaultBoolean.True; s.Label.ResolveOverlappingMode = ResolveOverlappingMode.HideOverlapped; WebChartControl4.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside; WebChartControl4.Legend.AlignmentVertical = LegendAlignmentVertical.Top; WebChartControl4.Series.Add(s); ((SideBySideStackedBarSeriesView)s.View).BarDistanceFixed = 5; if (i % 2 == 0) { GroupSeries(i, "0"); } else { GroupSeries(i, "1"); } WebChartControl4.Legend.Visible = true; } void GroupSeries(int seriesIndex, string group) { if (seriesIndex < WebChartControl1.Series.Count) { ISupportStackedGroup view = WebChartControl1.Series[seriesIndex].View as ISupportStackedGroup; if (view != null) view.StackedGroup = group; } } i根据6个状态得到12个表*两个不同大小按照我的需要。我从c#绑定了这个12系列。如果您有任何想法,请告诉我。i got 12 tables based on 6 status * two different size as per my need. i bind this 12 series from c#. please let me know if you have some idea.推荐答案 您已经提到图表ID为ID =WebChartControl4 和GroupSeries方法中你使用的是WebChartControl1。 制作WebChartControl4。 希望它有所帮助:)You have mentioned chart id as ID="WebChartControl4"and in the GroupSeries method you are using "WebChartControl1".Make it WebChartControl4.Hope it helps :) 这篇关于如何在Devexpress中按Stackbar Chart分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 00:41