This is a migrated thread and some comments may be shown as answers.

kendo chart dynamic series

2 Answers 476 Views
Charts
This is a migrated thread and some comments may be shown as answers.
don
Top achievements
Rank 1
don asked on 28 Mar 2013, 06:19 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 29 Mar 2013, 12:31 PM
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!
0
don
Top achievements
Rank 1
answered on 29 Mar 2013, 02:53 PM
Thank you!

That worked very well!
Tags
Charts
Asked by
don
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
don
Top achievements
Rank 1
Share this question
or