ChartArea and MVVM

8 posts, 0 answers
  1. ultramods
    ultramods avatar
    18 posts
    Member since:
    Sep 2009

    Posted 18 Feb 2011 Link to this post

    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

     

     

  2. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 23 Feb 2011 Link to this post

    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!
  3. ultramods
    ultramods avatar
    18 posts
    Member since:
    Sep 2009

    Posted 23 Feb 2011 Link to this post

    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
  4. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 01 Mar 2011 Link to this post

    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!
  5. ultramods
    ultramods avatar
    18 posts
    Member since:
    Sep 2009

    Posted 01 Mar 2011 Link to this post

    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)?
  6. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 03 Mar 2011 Link to this post

    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!
  7. ultramods
    ultramods avatar
    18 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2011 Link to this post

    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.


  8. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 09 Mar 2011 Link to this post

    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!
Back to Top