0

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>>()
                .Name("telemetryChart")
                .Title("")
                .Transitions(false)
                .DataSource(ds => ds.Read(read => read.Action("GetTelemetryTimeSeriesJson", "Equipment", new { equipmentId = Model.EquipmentId }))
                    .Group(g => g.Add(v => v.Series)))
                .Legend(legend => legend
                    .Position(ChartLegendPosition.Bottom))
                .Series(series =>
                {
                    series
                    .Line(value => value.Value, category => category.Category)
                    .Markers(false)
                    .Name("#:group.value#");
                })
                .CategoryAxis(axis => axis
                    .Date()
                    .BaseUnit(ChartAxisBaseUnit.Seconds)
                    .AxisCrossingValue(Model.ValueAxes.Select(x => x.AxisCrossingValue).ToArray())
                    .Labels(labels => labels
                        .Rotation("auto")
                        .Step(60))
                    .MajorGridLines(majorGridLines => majorGridLines
                        .Step(3600))
                )
                .ValueAxis(axis =>
                {
                    foreach (var valueAxis in Model.ValueAxes)
                    {
                        axis
                        .Numeric(valueAxis.Name)
                        .Labels(labels => labels
                            .Format("{0}" + " " + valueAxis.Unit));
                    }
                })
                .PersistSeriesVisibility(true)
            )

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.