Adding Lines dynamically kendo Line Chart

2 posts, 0 answers
  1. Suneeth
    Suneeth avatar
    1 posts
    Member since:
    Aug 2013

    Posted 09 Sep 2013 Link to this post

    Hi,

    I am trying to use Kendo Line Chart for my application and I want to know how i can add Lines dynamically I am using ASP.NET MVC (Razor).

    So far this is what I have

    @(Html.Kendo().Chart(Model.colorCart)
    .Name("chart")
    .Title("15°")

    .Legend(legend => legend
    .Position(ChartLegendPosition.Left)

    )
    .ChartArea(chartArea => chartArea
    .Background("transparent")
    )

    .Series(
    series =>
    {
    series.Line(l => l.Std_values).Name("Std"); //To be added dynamically 
    series.Line(l => l.Start_values).Name("Start"); //To be added dynamically 
    series.Line(l => l.Pred_values).Name("Pred"); //To be added dynamically 
    series.Line(l => l.End_values).Name("End"); //To be added dynamically 
    series.Line(l => l.Select_values).Name("Select"); //To be added dynamically 
    }
    )
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2622 posts

    Posted 10 Sep 2013 Link to this post

    Hello Suneeth,

    I am afraid your scenario is not supported out-of-the-box by Kendo UI Chart. As a possible workaround I can suggest adding new series via chart.options and recreate the chart:
    //get reference to the Chart widget
    var chart = $("#chart").data("kendoChart");
    //create and push new series
    chart.options.series.push({name: "newSeries", field: "someField", type: "line"});
    //refresh the Chart
    chart.refresh();

    Regards,
    Iliana Nikolova
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top