Customizing Legend Label with percentage

3 posts, 1 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 21 Sep 2009 Link to this post

    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. Answer
    Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 24 Sep 2009 Link to this post

    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.
  3. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 24 Sep 2009 Link to this post

    Yes, I did so on 22 sept... well can I have profile points for the suggestion :-P,
    Thanks
     bye
Back to Top