1
我正在构建一个堆积柱形图。我不知道进入它的系列的数量,因此我使用foreach来构建每个系列。我想为每个系列分类标签。通常对于像这样的东西,我会使用类别表达式,但无法弄清楚如何以我正在构建的方式进行操作。这就是它看起来像没有标签的地方,只是为了参考代码。如何设置动态堆积柱形图的分类标签
任何帮助,将不胜感激。
@(Html.Kendo().Chart()
.Name("chart")
.Theme("flat")
.Title("Issues Waterfall")
.DataSource(ds => ds
.ServerOperation(false)
)
.Series(series =>
{
series.Column(new double[] { 100 }).Name("Total").Color("Blue").Stack("Total");
foreach (var resp in Model.listResponsibleDowntime)
{
series.Column(new double?[] { resp.percent_pad }).Name(resp.resp_name).Color("White").Opacity(0).Labels(false).Tooltip(false).Stack(resp.resp_name);
series.Column(new double?[] { resp.percent_downtime }).Name(resp.resp_name).Color(resp.resp_color).Labels(lables => lables.Format("{0:n2}%").Visible(true).Position(ChartBarLabelsPosition.OutsideEnd)).Stack(resp.resp_name);
}
series.Column(new double?[] { Model.oee }).Name("Actual").Color("Green").Stack("Actual").Labels(lables => lables.Format("{0:n2}%").Visible(true).Position(ChartBarLabelsPosition.OutsideEnd));
})
.CategoryAxis(axis => axis
.MajorGridLines(lines => lines.Visible(false))
.Labels(model => model
.Rotation(0)
.Visible(true)
)
//.Categories(Model.listCategories)
)
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
.Margin(20, 50, 20, 50)
.Visible(false)
)
.ValueAxis(axis => axis
.Numeric()
.Min(0)
.Max(100)
.Labels(labels => labels.Format("{0:n0}%"))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= kendo.format('{0:n2}', value) #")
)
)