Binding Single Objects to a RadCartesianChart's BarSeries

2 posts, 0 answers
  1. Bryan
    Bryan avatar
    28 posts
    Member since:
    Jul 2008

    Posted 18 Jan 2013 Link to this post

    Hey there, I'm creating a project where I want to display attributes of specific objects in a chart. For example, I have 2 different loan objects (Current Loan and Proposed Loan) and I want to display each one of those object's "Tax Savings" in a bar chart. I am trying to do something EXACTLY like this:

    http://www.telerik.com/help/wpf/radchartingkit-series-barseries.html 

    But I want the properties themselves to be properties on my objects. I've tried basic bindings and I can't seem to get it to work. The objects bind find throughout my app it's just not functioning here. The code I've got is:

                                <telerikChart:RadCartesianChart Width="500" >

                                    <telerikChart:RadCartesianChart.HorizontalAxis>
                                        <chartView:CategoricalAxis/>
                                    </telerikChart:RadCartesianChart.HorizontalAxis>
                                    
                                    <telerikChart:RadCartesianChart.VerticalAxis>
                                        <chartView:LinearAxis/>
                                    </telerikChart:RadCartesianChart.VerticalAxis>

                                    <telerik:BarSeries>
                                        <telerik:BarSeries.DataPoints>
                                            <telerik:CategoricalDataPoint  Value="{Binding Path=CurrentLoan.TaxSavings}"
                                                      Category="Proposed Loan"/>
                                            <telerik:CategoricalDataPoint  Value="{Binding Path=ProposedLoan.TaxSavings}"
                                                      Category="Current Loan"/>
                                        </telerik:BarSeries.DataPoints>
                                    </telerik:BarSeries>

                                </telerikChart:RadCartesianChart>

    When It loads, it actually blanks out my entire "View" that the charts are supposed to be in. Any suggestions? Thank you
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 23 Jan 2013 Link to this post

    Hi Bryan,

    CategoricalDataPoint.Value is not a dependency property, so this scenario is not expected to work. You can either populate the values in code or provide an enumerable as ItemsSource for the BarSeries as shown in this example, and let the chart create the bars for you.

    Kind regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top