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

Multiple line series by data binding

7 Answers 284 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 15 Nov 2013, 06:18 PM
I'm trying to create a line series chart that displays multiple lines. The problem is, I'm using MVVM and thus need to bind the source from a view model, and the number of series will change at some time; sometimes it needs to show only 2 lines, other times it might display more than 10. However I failed to find a good example or tutorial on whether it is possible to manipulate the number of lines in MVVM environment, and if so, how. Could you provide a sample on how to bind a line series chart with dynamically changing source from view model?

7 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 18 Nov 2013, 03:09 PM

Hi Kevin,

Thank you for using RadControls foe Windows 8!

The RadChart control provides functionality for using dynamic series. You can first take a look at these articles from our online documentation:

I have also attached a runnable sample application that demonstrates how you can add series dynamically to the chart using MVVM. The Source property of the ChartSeriesProvider can be bound to a property from the view model that holds the collection of collections/view models.

Please, do not hesitate to contact us if you have further questions.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Erik
Top achievements
Rank 1
answered on 04 Feb 2014, 10:31 AM
Hi!

I was not sure if I should post this as a separate question, but it builds on this one.

My question: Is it also possible to databind multiple axes this way? My chart is created purely with databinding, having a DateTimeContinuousAxis for X and separate Y-axes for separate series.

Regards,
Erik
0
Rosy Topchiyska
Telerik team
answered on 06 Feb 2014, 12:33 PM
Hi Erik,

Thank you for the question.

Unfortunately, the RadCartesianChart control does not provide functionality to add axes similarly to the way you add dynamic series. Multiple axes can be added only by static series.

Let us know if you have other questions.

Regards,
Rositsa Topchiyska
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Erik
Top achievements
Rank 1
answered on 06 Feb 2014, 01:00 PM
Hi,

Ok. Is it possible to use dynamic series, and add the axes from code-behind afterwards? Or is it not possible at all to use multiple axes with dynamic data?

Regards,
Erik
0
Rosy Topchiyska
Telerik team
answered on 10 Feb 2014, 01:26 PM
Hi Erik,

I have prepared a sample project that demonstrates how you can add axes to the chart dynamically with the series. You have to implement your own series descriptor that in your case inherits from the CategoricalSeriesDescriptor and override its the CreateInstanceCore() method to set the VerticalAxis property of the concrete chart series.

I hope this is useful. Please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Erik
Top achievements
Rank 1
answered on 11 Feb 2014, 10:20 AM
Hi Rositsa,

Thanks, that was a smooth solution! However, when I zoom in the chart, the vertical-axis values dissapear, only the title i set is shown. Can I hook into an event and force redraw somehow?

FYI: I ran into problems when adding the CustomChartSeriesDescriptor-class to my class-library-project, and found a solution here: http://www.telerik.com/forums/could-not-load-assembly-telerik-windows-controls-navigation#JTG1FF9iYkKdhuPNP4K-cQ from WPF-component from 2009.

I guess it relates to my problem with PRISM here: http://www.telerik.com/forums/permalink/U4iMyMKScEeRVk33oDmTiQ

I appreciate your support, thanks!

Regards,
Erik




0
Rosy Topchiyska
Telerik team
answered on 13 Feb 2014, 10:24 AM
Hello Erik,

Thank you for contacting us.

The chart is forced to update its layout with the RadCartesianChart.InvalidateUI() method, but I do not think this will solve the problem. In the attached project from my previous answer the axes work as expected when zooming an panning. Could you please modify the project in order to reproduce the issue.

I look forward to your reply.

Regards,
Rositsa Topchiyska
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
Chart for XAML
Asked by
Kevin
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Erik
Top achievements
Rank 1
Share this question
or