Kendo Chart category axis fix number of labels

2019-02-26 05:00发布

问题:

I have a kendo chart with date time series on x-axis as below but i wanted to fix the number of labels on the axis. Could you please help me on this how to acheive.

@(Html.Kendo().Chart(Model.ParameterValueList)
                     .Name("chart")
                     .Title("Chart Title")
                     .DataSource(ds => ds
                         .Group(group => group.Add(model => model.Parameter.Name))
                     )
                     .Series(series =>
                            {
                                series.Line(Model.ParameterValueList).CategoryField("ReceiveTime").Field("Value").Stack(false);
                            })
                            .CategoryAxis(axis => axis
                                .Categories(model => model.ReceiveTime).Date().RoundToBaseUnit(true)
                                .Labels(l => l.Rotation(-45).Format("dd MMM yyyy hh:mm:ss").Step(2))                                       
                                .MajorGridLines(x=>x.Step(5))
                                .MajorTicks(x=>x.Size(5))
                            )
                            .Legend(legend => legend
                                .Visible(true).Position(ChartLegendPosition.Right)
                             )
                            .ChartArea(a => a.Width(800).Height(250))
                            .Tooltip(t => t.Visible(true).Template("${series.name} : ${value}"))
                       )