0
我想统计一个月内新用户的数量。但是,这是我收到的输出。如何将重复的月份分组为“Jan”,“Nov”。非常感谢你的帮助。在MVC图中按月分组
public ActionResult UserPerMonth()
{
var _con = new DBEntities();
ArrayList xValue = new ArrayList();
ArrayList yValue = new ArrayList();
var results = (from c in _con.Users select c);
results.ToList().ForEach(rs => yValue.Add(rs.id.ToString().Count()));
results.ToList().ForEach(rs => xValue.Add(rs.date.Value.ToString("MMM-yyyy")));
var chart = new Chart(width: 300, height: 200)
.AddTitle("Users per month")
.AddLegend()
.AddSeries(
chartType: "Column",
xValue: xValue,
yValues: yValue)
.GetBytes("png");
return File(chart, "image/png");
}
感谢您的帮助,我认为这部分有一个错字Month = n.Key, Count = n.Count(),但是代码不显示图表@James – jamietoh
道歉,是的,修复了错字 - 你可以试试。如果没有,请设置断点,看看'axis'的值是什么? –