将散点图与 GroupNameTemplate 一起使用有助于动态设置图表系列名称。类似于下面的代码片段:
<%= Html.Kendo().Chart(Model)
.Name("chart")
.Title("Stock Prices")
.DataSource(dataSource => dataSource
.Read(read => read.Action("_StockData", "Scatter_Charts"))
.Group(group => group.Add(model => model.Symbol))
.Sort(sort => sort.Add(model => model.Date).Ascending())
)
.Series(series =>
{
series.ScatterLine(model => model.Date, model => model.Close)
.Name("close")
.GroupNameTemplate("#= group.value # (#= series.name #)");
})
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.YAxis(axis => axis.Numeric()
.Labels(labels => labels
.Format("${0}")
.Skip(2)
.Step(2)
)
)
.XAxis(axis => axis.Date()
.Labels(labels => labels.Format("MMM"))
)
%>