我正在尝试将 Telerik Chart 绑定到IEnumerablge<MyModel>
内部局部视图
我的模特
public class MyModel
{
private string identifier;
private DateTime date;
private int visits;
}
局部视图
@model IEnumerable<MyModel>
@{
Html.Telerik().Chart(Model)
.Name("Visits")
.Legend(legend => legend.Visible(true).Position(ChartLegendPosition.Bottom))
.Series(series => {
series.Line("CurrentMonth").Name("Current Month")
.Markers(markers => markers.Type(ChartMarkerShape.Triangle));
series.Line("PrevMonth").Name("Previous Month")
.Markers(markers => markers.Type(ChartMarkerShape.Square));
})
.CategoryAxis(axis => axis.Categories(s => s.date))
.ValueAxis(axis=>axis.Numeric().Labels(labels=> labels.Format("{0:#,##0}")))
.Tooltip(tooltip => tooltip.Visible(true).Format("${0:#,##0}"))
.HtmlAttributes(new { style = "width: 600px; height: 400px;" });
}
出现以下错误:
CS1660: Cannot convert lambda expression to type 'System.Collections.IEnumerable' because it is not a delegate type
在以下代码行:
.CategoryAxis(axis => axis.Categories(s => s.date))
谢谢!