【发布时间】:2015-05-21 14:52:56
【问题描述】:
我正在尝试使用饼图来显示统计信息。数据在我的表中,我是这样得到的:
public class StatisticsAccess
{
public static object getTypesForStatistics()
{
var dbo = new UsersContext();
var all = (from a in dbo.Note
select a).ToList();
var results = all.GroupBy(item => item.language.lang)
.Select(g => new
{
language = g.Key,
Count = g.Select(l => l.language.lang).Count()
});
return (results.ToList());
}
}
控制器:
public ActionResult Index()
{
var results = Json(DAL.StatisticsAccess.getTypesForStatistics());
return View();
}
查看:
@(Html.Kendo().Chart()
.Name("chart")
.Title(title => title
.Text("Share of Internet Population Growth, 2007 - 2012")
.Position(ChartTitlePosition.Bottom))
.Legend(legend => legend
.Visible(false)
)
.Series(series => {
series.Pie(model => model.language, model => model.Count);
})
.DataSource(ds => ds.Read(read => read.Action("index", "Statistics")))
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0}%")
)
)
在我看来,series 属性中存在语法错误:
无法将 lambda 表达式转换为类型“字符串”
谁能解释我应该遵循的语法来修复这个错误? 谢谢
【问题讨论】:
标签: c# asp.net-mvc-4 kendo-ui telerik