This is a migrated thread and some comments may be shown as answers.

Legend auto generated items

2 Answers 97 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 05 Jul 2012, 01:59 PM
Hi,

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:RadChart.DefaultView>
                <Telerik:ChartDefaultView>
                    <Telerik:ChartDefaultView.ChartTitle>
                        <Telerik:ChartTitle Content="Refund Amounts By Bucket" Background="{x:Null}" Foreground="Black" OuterBorderBrush="{x:Null}" BorderBrush="{x:Null}" />
                    </Telerik:ChartDefaultView.ChartTitle>
                    <Telerik:ChartDefaultView.ChartLegend>
                        <Telerik:ChartLegend x:Name="RefundAmountsPieChartLegend" UseAutoGeneratedItems="True" Header="Buckets"/>
                    </Telerik:ChartDefaultView.ChartLegend>
                    <Telerik:ChartDefaultView.ChartArea>
                        <Telerik:ChartArea SmartLabelsEnabled="False" LegendName="RefundAmountsPieChartLegend"/>
                    </Telerik:ChartDefaultView.ChartArea>
                </Telerik:ChartDefaultView>
            </Telerik:RadChart.DefaultView>
            <Telerik:RadChart.SeriesMappings>
                <Telerik:SeriesMapping ItemsSource="{Binding RefundAmountsByBucket}" >
                    <Telerik:SeriesMapping.SeriesDefinition>
                        <Telerik:PieSeriesDefinition ItemLabelFormat="#%{P0}" RadiusFactor="0.75">
                            <Telerik:PieSeriesDefinition.LabelSettings>
                                <Telerik:RadialLabelSettings ShowZeroValueLabels="False" SpiderModeEnabled="True" ShowConnectors="True" Distance="15"/>
                            </Telerik:PieSeriesDefinition.LabelSettings>
                        </Telerik:PieSeriesDefinition>
                    </Telerik:SeriesMapping.SeriesDefinition>
                    <Telerik:SeriesMapping.ItemMappings>
                        <Telerik:ItemMapping FieldName="Bucket" DataPointMember="XCategory"/>
                        <Telerik:ItemMapping FieldName="RefundAmount" DataPointMember="YValue"/>
                    </Telerik:SeriesMapping.ItemMappings>
                </Telerik:SeriesMapping>
            </Telerik:RadChart.SeriesMappings>
        </Telerik:RadChart>

Thanks!

2 Answers, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 10 Jul 2012, 08:11 AM
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,
Rosko
the Telerik team

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

0
Jeremy
Top achievements
Rank 1
answered on 10 Jul 2012, 02:05 PM
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!
Tags
Chart
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or