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

[Solved] Generating chart data dynamically.

5 Answers 153 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 26 Nov 2012, 01:22 PM
Hello Gurus,

Here is my situation. I have dragged and dropped a xaml chart control onto my form. What I want to be able to do is add all the content such as series dynamically using code behind. The reason for this is I am having data with coming in with different values. In this case based on what value is chosen in a dropdownlist, the data returned will be either charted in one series or two. So it is my desire to be able to add these series dynamically to the chart. Can anyone here please provide a code example of how I would do this from start to finish?

Many thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 28 Nov 2012, 03:04 PM
Hi James,

Thank you for contacting us and for your question.

Our Charting component has the ability to generate dynamic series, based on logical description. You can utilize the ChartSeriesProvider component, more information and demo code may be found in this documentation article:

http://www.telerik.com/help/windows-8-xaml/radchart-cartesianchart-series-categorical-dynamicseries-howtocreatebarchartdynamicseries.html

I hope this information is useful. Let me know if I can assist you further.

Regards,
Georgi
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
James
Top achievements
Rank 1
answered on 28 Nov 2012, 03:48 PM
This seems like it may be perfect. I will reply when it is tested. Many thanks
0
James
Top achievements
Rank 1
answered on 28 Nov 2012, 03:54 PM
Question.
In my code behind should I just add additional 'SeriesDescriptor' objects to the ChartSeriesProvider  for each series I would want to add?
0
Ivaylo Gergov
Telerik team
answered on 03 Dec 2012, 01:11 PM
Hi James,

Thank you for getting back to us.

If I understand you correctly you want to have more than one SeriesDescriptor and choose where each of them will apply. 
One way is to define let's say three different SeriesDescriptors and use their CollectionIndex property to define where they will apply. Keep in mind that all the undefined indexes of your collection will apply to the first defined Descriptor.
Another approach which gives you more flexibility is to use the ChartSeriesProvider.SeriesDescriptorSelector property. You need create a custom descriptor selector class that inherits from ChartSeriesDescriptorSelector and override its SelectDescriptor(...) method where you can choose the correct series descriptor for each item in your business collection. I have prepared you a sample project using the SeriesDescriptorSelector. Please, find the attached file.

I hope this helps. If you have any other questions do not hesitate to contact us again.

 

Greetings,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
James
Top achievements
Rank 1
answered on 21 Dec 2012, 02:35 PM
Thanks again for the promptness of your reply I will check out the sample.
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
Georgi
Telerik team
James
Top achievements
Rank 1
Ivaylo Gergov
Telerik team
Share this question
or