我搜索并尝试了许多不同的方法,但找不到找到对柱形图进行排序的方法。我们希望在顶部而不是底部具有最大数量。
我无法更改查询,但需要对图表进行排序。
我尝试了以下方法:
ColumnChartMachine.Series(0).Sort(PointSortOrder.Descending, "Y")
和
ColumnChartMachine.DataManipulator.Sort(PointSortOrder.Descending, "Y", "SeriesMachines")
在这里,我将Y更改为不同的值,然后将Ascending / Descending更改为不同的值,只是为了查看它是否可以起作用,但是没有运气。
任何的想法?
我无法更改查询,但需要对图表进行排序。
您不需要更改查询,应该可以使用以下两个选项之一:
DataTable
还是a List<T>
,而无需更改查询,都可以在客户端上对结果进行排序)。DataBind
例子
假设您在DataTable
或中包含数据List<T>
,如下所示:
var table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Value", typeof(int));
table.Rows.Add("FIT programmatiestation", 1);
table.Rows.Add("Atlas 1N36", 1);
table.Rows.Add("anilox cleaner", 1);
table.Rows.Add("Nietjespistool", 1);
table.Rows.Add("MORLOCK", 2);
table.Rows.Add("MA 2200 4k!", 2);
table.Rows.Add("Catena klein 2E21", 2);
table.Rows.Add("Automatische kokerslitter 76 mm", 2);
table.Rows.Add("ROP", 2);
table.Rows.Add("RDC 1", 4);
myChart.Series[0].ChartType =
System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;
myChart.ChartAreas[0].AxisX.Interval = 1;
选项1-排序数据源:
myChart.DataSource = new DataView(table, "", "Value ASC", DataViewRowState.CurrentRows);
myChart.Series[0].XValueMember = "Name";
myChart.Series[0].YValueMembers = "Value";
myChart.DataBind();
选项2-调用后对图表进行排序DataBind
:
myChart.DataSource = table;
myChart.Series[0].XValueMember = "Name";
myChart.Series[0].YValueMembers = "Value";
myChart.DataBind();
myChart.Series[0].Sort(
System.Windows.Forms.DataVisualization.Charting.PointSortOrder.Ascending);
两者均产生预期结果:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句