首页新闻找找看学习计划

DevExpress中 ChartControl控件制作柱形图(bar)时,X轴排序问题

0
悬赏园豆:10 [待解决问题]

查询时已经按月份排序,但是柱状图是按柱添加上去,所以第一根柱没的5月和6月的数据,排序时就排到后面去了,现在我想让它按1-12月排序,该怎么写?

List<PurchaseStaticsist> lstPurchaseStaticsist = (from a in productionPurchaseOrderRepository.GetQuery(query_Order.Predicate)
join b in productionPurchaseDetailRepository.GetQuery(query.Predicate) on a.ProductionPurchaseOrderId equals b.ProductionPurchaseOrderId
where b.PurchaseStatus == "采购完成"
group b by new
{
//Year = SqlFunctions.DateName("year", b.LastUpdateTime),
//Month = SqlFunctions.DateName("month", b.LastUpdateTime),
Year = b.LastUpdateTime.Year,
Month = b.LastUpdateTime.Month,
a.PurchaseOrderType
} into g
select new
{
g.Key.Year,
Month=g.Key.Month,
g.Key.PurchaseOrderType,
TotalAmount = g.Sum(a => a.Money) / 10000,
}).Distinct().Where(a=>a.TotalAmount>0).OrderBy(a => a.Month).Select(a => new PurchaseStaticsist() { Year = a.Year.ToString(), Month = a.Month.ToString(), PurchaseOrderType = a.PurchaseOrderType, TotalAmount = a.TotalAmount }).ToList();

chartControl1.Series.Clear();
foreach (var item in parts_TypeRepository.GetQuery(a => a.RecordStatus))
{
// 柱状图里的第一个柱
Series Series1 = new Series(item.TypeName, ViewType.Bar);
Series1.DataSource = lstPurchaseStaticsist.Where(a => a.PurchaseOrderType == item.TypeName);
Series1.ArgumentScaleType = ScaleType.Qualitative;
// 以哪个字段进行显示
Series1.ArgumentDataMember = "Month";
Series1.ValueScaleType = ScaleType.Numerical;
// 柱状图里的柱的取值字段
Series1.ValueDataMembers.AddRange(new string[] { "TotalAmount" });
(Series1.Label as BarSeriesLabel).Position = BarSeriesLabelPosition.Top;
(Series1.Label as BarSeriesLabel).ResolveOverlappingMode = ResolveOverlappingMode.Default;
Series1.LabelsVisibility = DefaultBoolean.True;
chartControl1.Series.Add(Series1);
}

午夜与鬼共舞丶的主页 午夜与鬼共舞丶 | 初学一级 | 园豆:134
提问于:2019-12-04 08:22
< >
分享
所有回答(1)
0

显然柱子的顺序是chartControl1.Series的元素顺序
那么就是parts_TypeRepository.GetQuery(a => a.RecordStatus)这个顺序不对
你就按照月份排序一下嘛
foreach (var item in parts_TypeRepository.GetQuery(a => a.RecordStatus).Orderby(t=>t.Month))

猝不及防 | 园豆:1695 (小虾三级) | 2019-12-04 14:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册