I am building a stacked column chart. I don't know the number of series going into it so I am using a foreach to build each series. I want a category label for each of the series. Typically for something like this I would use the categoryexpression but can't figure out how to do it with the way I am building. Here is what it looks like w/o the labels, just for reference to code.
Any help would be appreciated.
@(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) #")
)
)
I know it's old but this might help the next person because Telerik's documentation wont.
In your foreach you need to pass the the column builder an IEnumerable class and then tell it which field is the category and which is the value:
And in the foreach: