首页新闻找找看学习计划

ChartControl控件,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-11-29 09:24
< >
分享
所有回答(1)
0

你定义以月进行的分组应该就好了

https://www.evget.com/article/2012/10/12/17750.html

我是小小学生 | 园豆:209 (菜鸟二级) | 2019-11-29 10:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册