Binding multiple series to RadCartesianChart

22 posts, 0 answers
  1. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 27 Jun 2012 Link to this post

    Hi there,

    I need to create a dynamic number of line-series on a RadCartesienChart. Unfortunately I couldn't find a ItemsSource-property on the chart control itself, so I had to add the series through code-behind, which in a MVVM-Architecture is quite messy. The moment to add the series was the Load-Event of the chart control - calling out to the ViewModel and retrieving the data. In my app, the user can perform an action, that would need to force a redraw of that chart and ultimately adding one more or remove one series from the chart.

    In my scenario I would need to call from the ViewModel to the View-SourceBehind to somehow redraw the chart with the currently valid series.

    Is there a plan to make the series of a chart bindable in the future?

    Thanks,
    Steve

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 28 Jun 2012 Link to this post

    Hello Steve,

    Thanks for the question.
    We currently do not have any official plans but thanks for the feedback. We'll keep this in mind and if more people request this we will definitely consider making the chart more MVVM friendly.

    Currently you can isolate the logic for populating the Series collection in a custom view model that has an items source property that you can bind to. It should be a simple matter of clearing the Series collection and populating it with the series from the ItemsSource.

    Please write again if you have other questions.

    All the best,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Shayne
    Shayne avatar
    3 posts
    Member since:
    Sep 2012

    Posted 12 Sep 2012 Link to this post

    Hello Steve,

    Binding within the MVVM pattern and any of the Rad "Chart" controls is certainly supported.  Here is an example of binding within the RadCartesianChart.  The most important piece of this example is the node telerikChart:LineSeries this is where you set the ItemsSource. Futhermore, in the LineSeries.CategoryBinding and the LineSeries.ValueBinding 




    the XAML

    <telerikChart:RadCartesianChart x:Name="chart" Height="567">
        <telerikChart:RadCartesianChart.Grid>
            <telerikChart:CartesianChartGrid MajorLinesVisibility="XY" MajorXLineDashArray="5, 5" MajorYLineDashArray="5, 5">
                <telerikChart:CartesianChartGrid.MajorXLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Stroke" Value="Gray" />
                    </Style>
                </telerikChart:CartesianChartGrid.MajorXLineStyle>
                <telerikChart:CartesianChartGrid.MajorYLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="Stroke" Value="Gray" />
                    </Style>
                </telerikChart:CartesianChartGrid.MajorYLineStyle>
            </telerikChart:CartesianChartGrid>
        </telerikChart:RadCartesianChart.Grid>
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:LinearAxis LineStroke="{StaticResource PhoneDisabledBrush}" LineThickness="2" />
        </telerikChart:RadCartesianChart.VerticalAxis>
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:CategoricalAxis LineStroke="{StaticResource PhoneDisabledBrush}" LineThickness="2" LabelFitMode="Rotate" />
        </telerikChart:RadCartesianChart.HorizontalAxis>
        
         <telerikChart:LineSeries x:Name="dataSeries" ItemsSource="{Binding QueryData, Mode=TwoWay}" ShowLabels="True">
            <telerikChart:LineSeries.ValueBinding>
                 <telerikChart:PropertyNameDataPointBinding PropertyName="Value"/>
               </telerikChart:LineSeries.ValueBinding>
               <telerikChart:LineSeries.CategoryBinding>
                 <telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
               </telerikChart:LineSeries.CategoryBinding>
       </telerikChart:LineSeries>
         
    </telerikChart:RadCartesianChart>


    the ViewModel

    private List<ChartData> queryData;
    public List<ChartData> QueryData
    {
        get
        {
             return queryData;
        }
        set
        {
             queryData = value;
             RaisePropertyChanged(() => QueryData);
        }
    }

    the Model
    public class ChartData
    {
         public string Category { get; set; }
         public double Value { get; set; }
    }

    Please let me know if you have any questions.

    Shayne Boyer
    Telerik MVP
  5. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 13 Sep 2012 Link to this post

    Hi Shayne,

    Thanks for your answer.

    It is certainly true, that you can bind values to a predefined series (predefined means through XAML) as you described below. However I don't know at compile time how many series to display. So I would need the Series Property on the RadCartesianChart Class to be a Dependency Property in some way - not exactly, but you get the idea.

    Let me give an example: Let's say the chart is displaying a number of stocks and the user can pick through check boxes which stock to display. You would need to create a LineSeries per stock and bind the values per category, e.g. value per given day, to that particular series.

    Makes sense?

    I've created an app, that you can download from the store (trial/paid) or have a look at the screenshots. It will give you a clear idea what I mean. app.net/traXs 

    Cheers,
    Steve
  6. Shayne
    Shayne avatar
    3 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    Steve,



    Yes I see what you are trying to accomplish in the MVVM pattern. You are looking to bind multiple LineSeries correct?



    Shayne
  7. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 13 Sep 2012 Link to this post

    Yes that is correct.

    Any way in doing that right now or planned for future releases?

    Steve
  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 14 Sep 2012 Link to this post

    Hi Steve,

    Thanks for the question.
    Currently we have not planned on making the series bindable, however since you are asking we will consider implementing this in a future release.
    Please write again if you have other questions.

    Regards,
    Victor
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  9. Christoph
    Christoph avatar
    1 posts
    Member since:
    Feb 2012

    Posted 15 Oct 2012 Link to this post

    Hi victor
    I have the same problem as steve. It would be nice to have this feature (series bindable for mvvm support) in future.
    Kind regards
    Chris
  10. Matt
    Matt avatar
    10 posts
    Member since:
    Jul 2011

    Posted 28 Feb 2013 Link to this post

    Hi Victor,

    I have the same issue.
    Was hoping that this would be fixed in Q1 2013 to come in with the RadLegend

    Best Regards,

    Matt
  11. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 04 Mar 2013 Link to this post

    Hi guys,

    Given that this thread has grown with requests we will implement the bindable series in the next release.
    Let us know if you need anything else.

    Greetings,
    Victor
    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.
  12. Steve Behrendt
    Steve Behrendt avatar
    12 posts
    Member since:
    Feb 2010

    Posted 04 Mar 2013 Link to this post

    Hi guys!

    Excellent! Thanks for that. Once it's out I'll try it and let you know!

    Would be good to post an information her in the thread, once the feature actually shipped!

    Keep up the good work,
    Steve
  13. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 04 Mar 2013 Link to this post

    Hi Steve,

    Will do.

    All the best,
    Victor
    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.
  14. Jack
    Jack avatar
    4 posts
    Member since:
    Mar 2013

    Posted 29 Mar 2013 Link to this post

    Hi Victor,

    When is the next Telerik release scheduled? I am working on a project that depends on this feature and the project will end in a few months.

    Jack
  15. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 01 Apr 2013 Link to this post

    Hi Jack,

    Our next release is scheduled for mid June. Is this acceptable to you? 

    Kind regards,
    Victor
    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.
  16. Jack
    Jack avatar
    4 posts
    Member since:
    Mar 2013

    Posted 02 Apr 2013 Link to this post

    June is our expected delivery month.

    Would it be possible to obtain betas of the relevant assemblies before then?

    Thank you.
  17. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 04 Apr 2013 Link to this post

    Hello Jack,

    We will be releasing a Service Pack mid April. We will do our best to include the updated chart.

    Kind regards,
    Victor
    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.
  18. JSmith
    JSmith avatar
    1 posts
    Member since:
    Jun 2013

    Posted 19 Jun 2013 Link to this post

    I need that same, Is that is available in RadControls for WPF Q2 2013?

  19. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 24 Jun 2013 Link to this post

    Hi JSmith,

    Our RadChartView control supports automatic generation of a dynamic number of series through its ChartSeriesProvider API. You can read more about it in this help topic.
     
    Regards,
    Petar Kirov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  20. Bojan
    Bojan avatar
    11 posts
    Member since:
    Jan 2014

    Posted 02 Apr 2014 Link to this post

    What is the status of this?
    has it been implemented in Windows phone controls?
  21. Ivaylo Gergov
    Admin
    Ivaylo Gergov avatar
    661 posts

    Posted 04 Apr 2014 Link to this post

    Hello,

    Yes, this feature has been implemented. Now the RadChart.Series property has a public setter and it could be bound.

    Let me know if you have any questions.

    Regards,
    Ivaylo Gergov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  22. Varun
    Varun avatar
    1 posts
    Member since:
    Jul 2015

    Posted 01 Jul 2015 in reply to Ivaylo Gergov Link to this post

    Hi

    I need this feature for the xamarin forms env. The chart series is not bindable and it would be easy if you can provide this feature like the windows phone one.

  23. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 06 Jul 2015 Link to this post

    Hi Varun,

    Currently, we do support for this feature for Xamarin Forms but we will consider supporting it in future. I have logged this in our feedback portal where you can track its progress.

    Regards,
    Tsvyatko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner