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

ChartArea and MVVM

7 Answers 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
ultramods
Top achievements
Rank 1
ultramods asked on 18 Feb 2011, 02:01 PM
Hello is it possible to add chart areas based on a property from the View Model?

VM
public ObservableCollection<string> Areas
{
    get {return new ObservableCollection<string>() {"chart1", "chart2"};}
}

Expected XAML generated by a DataTemplate or value converter etc

<

 

 

telerik:ChartArea x:Name="chart1" LegendName="chartLegend"/>

 

 

 

<telerik:ChartArea x:Name="chart2" LegendName="chartLegend"/>

Thanks

 

 

7 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 23 Feb 2011, 12:36 PM
Hi ultramods,

You cannot bind the x:Name attribute for any silverlight or WPF control (button, chart, etc.) so your code will not work without changes. What exactly are you trying to achieve? What is the desired functionality of your application?

Kind regards,
Vladimir Milev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
ultramods
Top achievements
Rank 1
answered on 23 Feb 2011, 10:06 PM
HI, I would like to create chartareas dynamically based on my representation of the chart configuration in the VM.

I am trying to achieve something similar to this post http://www.telerik.com/community/forums/silverlight/chart/multi-charts-on-single-x-axis.aspx
0
Vladimir Milev
Telerik team
answered on 01 Mar 2011, 09:24 AM
Hello ultramods,

This will work, you just can't use x:Name in the template.

Kind regards,
Vladimir Milev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
ultramods
Top achievements
Rank 1
answered on 01 Mar 2011, 09:30 AM
Ok thanks, if I can't use the x:Name property how can I link the chart area to the Series Mappings (as series mapping has a chartArea and ChartAreaName properties)?
0
Vladimir Milev
Telerik team
answered on 03 Mar 2011, 09:14 AM
Hi ultramods,

These properties are not mandatory. They are only used if you have two or more instances of ChartArea within a single RadChart instance. My suggestion is to simply place a RadChart in the data template and then the series mappings will be referring to its default chart area.

All the best,
Vladimir Milev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
ultramods
Top achievements
Rank 1
answered on 03 Mar 2011, 09:29 AM
But I need to have multiple chart areas, each chart area will have its own x axis. The scenario is this, imagine I have 3 Series:
  • 2 Mass series (tonne)
  • 1 Volume Series (kSM3)

 

I would like to have 2 independent X axis, 1 for Mass and one for Volume, therefore I need to have 2 chart areas.

I want to create each chart area based on the view model and then bind the series data to each chart area using a series mapping property in the view model and a collection representing all the data/series from the view model.

The approach needs to be completely dynamic as the user can configure the charts using a wizard.


0
Vladimir Milev
Telerik team
answered on 09 Mar 2011, 10:52 AM
Hi ultramods,

Thanks for this clarification. Unfortunately the requirement to have different series mappings for each chart is not possible with the current version of RadChart. If you can have the same mappings for each chart it would be trivial to generate a dynamic number of charts, however, different mappings require a more complex logic and you will need to write some code in order to do that. It can be done, but not in MVVM.

Best wishes,
Vladimir Milev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Chart
Asked by
ultramods
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
ultramods
Top achievements
Rank 1
Share this question
or