I have a controller method that returns data to be shown on the kendo-mvc chart. Number of series I want to show is determined on the server side. What I want to do is to show multiple series on the graph, which I succeeded, but what I can not accomplish is to bind specific series to specific axis. For example: I have 3 series with values over the time: temperature 1 and temperature 2 which should be bound to the left vertical axis that shows temperature value and pressure series that shows value on the right vertical pressure axes. Lower is my code that shows series but without binding to the specific axes. Series are always bound to the first axes.

Actually I managed to accomplish this by using view model at the view level, but when using data source like in the following example I can't manage to accomplish required. It would be most logical to me if the method Line() would have axis argument beside category and value, but it doesn't have.

@(Html.Kendo().Chart<Novolyze.VOD.WebUI.Models.SeriesValue<object, DateTime>>()
                .DataSource(ds => ds.Read(read => read.Action("GetTelemetryTimeSeriesJson", "Equipment", new { equipmentId = Model.EquipmentId }))
                    .Group(g => g.Add(v => v.Series)))
                .Legend(legend => legend
                .Series(series =>
                    .Line(value => value.Value, category => category.Category)
                .CategoryAxis(axis => axis
                    .AxisCrossingValue(Model.ValueAxes.Select(x => x.AxisCrossingValue).ToArray())
                    .Labels(labels => labels
                    .MajorGridLines(majorGridLines => majorGridLines
                .ValueAxis(axis =>
                    foreach (var valueAxis in Model.ValueAxes)
                        .Labels(labels => labels
                            .Format("{0}" + " " + valueAxis.Unit));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.