MVVM binding to RadChart ...

3 posts, 0 answers
  1. Rob Ainscough
    Rob Ainscough avatar
    188 posts
    Member since:
    Jan 2010

    Posted 24 Jun 2015 Link to this post

    This is my first usage or RadChart and I wen thru the online documentation/examples but can't seem to get the RadChart binding to work.  I've verified my observableCollection and data values are there, just not binding.  I'm probably missing something easy ... here is the XAML:


    <telerik:RadChart x:Name="SizeTrendingRadChart" Grid.Row="2" Grid.RowSpan="4" Grid.Column="7" Grid.ColumnSpan="2" Margin="2" ItemsSource="{Binding Path=Sizes}">
                    <telerik:ChartTitle Content="Market Trend" HorizontalAlignment="Center" Height="20" FontSize="9" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="Black" OuterBorderBrush="{x:Null}" Padding="1"  />
                    <telerik:ChartLegend Visibility="Collapsed" />
            <telerik:SeriesMapping LegendLabel="Rate" CollectionIndex="0">
                    <telerik:LineSeriesDefinition ShowItemLabels="True"/>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="{Binding CurrentSizeRate}"/>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="{Binding TotalSizeRentRates}"/>

    I basically used your documentation example and just adjusted for my needs, but I'm not seeing my data in the Chart.  No errors, just nothing is displayed.

    Any suggestions?

    Thanks, Rob.


  2. Martin Ivanov
    Martin Ivanov avatar
    1475 posts

    Posted 25 Jun 2015 Link to this post

    Hello Rob,

    RadChart is our old charting control which has many known issues and limitations. This is why we created the new RadChartView suite which has better implementation and improved performance. Also, the new suite is very flexible and easier to set up. You can read about the differences between the controls in the RadChart vs. RadChartView help article. In general I recommend you to use RadChartView instead of RadChart.

    You can display your data with the RadCartesianChart, which is part of the RadChartView suite, with the following definition:
    <telerik:RadCartesianChart x:Name="SizeTrendingRadChart">
            <telerik:LinearAxis />
            <telerik:CategoricalAxis />
        <telerik:LineSeries ValueBinding="CurrentSizeRate" CategoryBinding="TotalSizeRentRates" ItemsSource="{Binding Path=Sizes}" />
    However, as I can see you want to display numbers in both dimensions (X axis, Y axis) so you can consider using ScatterLineSeries instead of LineSeries. In addition you can take a look at the Create Data-Bound Chart help article.

    Please give the new chart a try and let me know if it works for you.

    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
  3. Rob Ainscough
    Rob Ainscough avatar
    188 posts
    Member since:
    Jan 2010

    Posted 25 Jun 2015 in reply to Martin Ivanov Link to this post

    Hi Martin,

    I was able to resolve my issue, ItemsSource needed to be under the SeriesMapping element and the FieldName need to NOT have "{Binding ..." prefix, just the name of the property being bound.


    I will take a look at RadChartView, hopefully it's easier to implement than RadChart.


    Cheers, Rob.

Back to Top