我的 LoggedUserHome.Controller 对图表有此操作
public ActionResult GetGender()
{
var AllGender = new List<string>(from c in db.tbl_Profile select c.sex).ToList();
var Groping = AllGender
.GroupBy(i => i)
.Select(i => new { sex = i.Key, CountGet = i.Count() }).ToArray(); //get a count for each
var key = new Chart(width: 300, height: 300)
.AddSeries(
chartType: "pie",
legend: "Gender Popularity",
xValue: Groping, xField: "sex",
yValues: Groping, yFields: "CountGet")
.Write("gif");
return null;
}
在我看来,我已经给出了
<img src="/LoggedUserHome/GetGender"/>
感谢 Nexuss ToArray() 的建议,我设法通过读取数据库来填充图表。非常感谢 Nexuzz