Legend auto generated items

3 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    5 posts
    Member since:
    Jul 2012

    Posted 05 Jul 2012 Link to this post


    I have a pie chart set up, and I've been following the tutorial at http://www.telerik.com/help/wpf/radchart-features-chart-legend.html to set up the legend. I have the UseAutoGeneratedItems set to true for the legend, but the items in the legend are showing as "Item 1", "Item 2", ...etc. Isn't the auto generation supposed to use the categories that the chart is set up to use? Here's the code for the chart:

    <Telerik:RadChart Name="RefundAmountsByBucketChart" Grid.Row="1" Grid.Column="1" Background="White" Margin="5,5,10,5">
                            <Telerik:ChartTitle Content="Refund Amounts By Bucket" Background="{x:Null}" Foreground="Black" OuterBorderBrush="{x:Null}" BorderBrush="{x:Null}" />
                            <Telerik:ChartLegend x:Name="RefundAmountsPieChartLegend" UseAutoGeneratedItems="True" Header="Buckets"/>
                            <Telerik:ChartArea SmartLabelsEnabled="False" LegendName="RefundAmountsPieChartLegend"/>
                    <Telerik:SeriesMapping ItemsSource="{Binding RefundAmountsByBucket}" >
                            <Telerik:PieSeriesDefinition ItemLabelFormat="#%{P0}" RadiusFactor="0.75">
                                    <Telerik:RadialLabelSettings ShowZeroValueLabels="False" SpiderModeEnabled="True" ShowConnectors="True" Distance="15"/>
                            <Telerik:ItemMapping FieldName="Bucket" DataPointMember="XCategory"/>
                            <Telerik:ItemMapping FieldName="RefundAmount" DataPointMember="YValue"/>

  2. Rosko
    Rosko avatar
    137 posts

    Posted 10 Jul 2012 Link to this post

    Hi Jeremy,

    As I understood, you trying to set the label in the legend for each item in your series. To do so you will need to do two things. The first is to introduce a new string property in your class, which will be the name of the instance. Second, you have to do an item mapping for the legend lebel.
    <telerik:ItemMapping DataPointMember="LegendLabel" FieldName="StringProperty"/>

    I hope this is what you are after.

    Kind regards,
    the Telerik team

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

  3. DevCraft R3 2016 release webinar banner
  4. Jeremy
    Jeremy avatar
    5 posts
    Member since:
    Jul 2012

    Posted 10 Jul 2012 Link to this post

    Awesome, that's exactly what I was going for! I already had the string property set up, was just missing the ItemMapping. Thanks so much!
Back to Top