这是我目前正在运行的代码我想知道在使用 mvc 图表时这两件事是否可行?以及如何去做
我的控制器
public ActionResult CharterColumn()
{
ArrayList xValue = new ArrayList();
ArrayList yValue = new ArrayList();
var results = (from c in db.Timesheets select c);
results.ToList().ForEach(rs => xValue.Add(rs.Date));
//I want to format this to show the only the months on the x axis
results.ToList().ForEach(rs => yValue.Add(rs.Hours));
//And I want to calculate the sum of the hours for each month worked by a specific employee
new Chart(width: 800, height: 400, theme: ChartTheme.Yellow)
.AddTitle("Test")
.AddSeries("Default", chartType: "Column", xValue: xValue, yValues: yValue)
.Write("bmp");
return null;
}
和我的看法
<div>
<img src= "@Url.Action("CharterColumn")" alt="Chart"/>
</div>