kendo chart dynamic series

3 posts, 2 answers
  1. Answer
    don
    don avatar
    19 posts
    Member since:
    Dec 2008

    Posted 28 Mar 2013 Link to this post

    I currently have a two step process for my kendo charts. The first process is allowing the user to select the datasets (series) they want on the chart. They then choose a template. A template is the graph settings ex (color theme, chart type line, bar, circle ect.).

    Currently if a user selects the datasets they want i return the series information to the graph and the graph is then populated with the template settings.

    I also allow the user to change the template settings on the fly. For example a Bar chart to Line, Area, Circle ect. They can also change the theme. The issue becomes when the first load is set, the series information that i pass is:{
    [name: "string", data: []],
    [name: "string", data: []]
    }
    when i inspect the series object after the change on the template I see the following added to the object:{
    [name: "string",
    data: [],
    type: "area",
    color: "ff6800",
    ect...
    ],
    [name: "string",
    data: [],
    type: "area",
    color: "ff6800",
    ect...
    ],
    }

    The issue becomes that I can modify my object type to the correct selected type. I can even change the color value to a differen color for each series. However, because I am using the Kendo Themes, the chart background will change but then the series colors wont match. I could come up with a function to choose the background color for the chart and then choose what colors you want for your series. But I would rather use the kendo methods if possible.

    I also think if i clear out that object and just use the settings and data I am passing it could work. However, I dont want to have to go to the database each time a page level changes is made and I also noticed that my object even if i create a temp object is given all of the chart properties.

    Thank you in advance!
  2. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2812 posts

    Posted 29 Mar 2013 Link to this post

    Hello,

    Thank you for the detailed explanation. This is a scenario that we'd like to support via a public API, but we can only offer a workaround at the moment.

    You'll need to keep a deep copy of the chart options before passing them in. This way you can recreate the chart with only your original options.

    var options = { ... };

    $("#chart").kendoChart(
        // No side effects on options
        $.extend(true, {}, options)
    );

    I've prepared a demo here: http://jsbin.com/ulohof/1/edit

    I hope this helps.

    Regards,
    Tsvetomir Tsonev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. don
    don avatar
    19 posts
    Member since:
    Dec 2008

    Posted 29 Mar 2013 Link to this post

    Thank you!

    That worked very well!
Back to Top