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

Customizing Legend Label with percentage

2 Answers 185 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 21 Sep 2009, 07:57 AM
Hello to everybody,
I've got a pie chart with 30 pieces, some are really small and end-user cannot read the value, I was wondering if it's possible to have the Legend label item (ChartLegendItem) to show the Text with the percentage between (), for example Milan (40%), Rome (10%)

The Item mapping of the series are defined in this way :

 sm.ItemMappings.Add(new ItemMapping("Description", DataPointMember.XCategory)); 
            sm.ItemMappings.Add(new ItemMapping("Percentage",DataPointMember.YValue)); 
            sm.ItemMappings.Add(new ItemMapping("Description", DataPointMember.LegendLabel)) 

and looking at the forum I was able to catch the style but not able to modify it :

 <Style x:Name="CustomLegendItemStyle" TargetType="telerikCharting:ChartLegendItem"
                <Setter Property="Foreground" Value="White" /> 
                <Setter Property="FontSize" Value="9" /> 
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="telerikCharting:ChartLegendItem"
                            <Grid VerticalAlignment="Top"
                                <Grid.ColumnDefinitions> 
                                    <ColumnDefinition Width="Auto" /> 
                                    <ColumnDefinition Width="*" /> 
                                </Grid.ColumnDefinitions> 
                                <Rectangle x:Name="PART_LegendItemMarker" Style="{TemplateBinding ItemStyle}" /> 
                                <TextBlock Grid.Column="1" Margin="5" VerticalAlignment="Center" Text="{TemplateBinding Label}" FontSize="11" Foreground="#FFFFFFFF" /> 
                            </Grid> 
                        </ControlTemplate> 
 
                    </Setter.Value> 
                </Setter> 
            </Style> 

anyone can help me on this?
Thanks
Paolo





2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Milev
Telerik team
answered on 24 Sep 2009, 12:32 PM
Hello Paolo,

Unfortunately we don't have a similar functionality like Label Format Expressions for the chart legend items. However, you can manually set the DataPoint.LegendLabel to a custom text or you can use an ItemMapping to map it. We will consider adding format expressions for the legend items.

Greetings,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michele
Top achievements
Rank 2
answered on 24 Sep 2009, 12:36 PM
Yes, I did so on 22 sept... well can I have profile points for the suggestion :-P,
Thanks
 bye
Tags
Chart
Asked by
Michele
Top achievements
Rank 2
Answers by
Vladimir Milev
Telerik team
Michele
Top achievements
Rank 2
Share this question
or