RadPieChart LabelFormat

2 posts, 0 answers
  1. Richard
    Richard avatar
    7 posts
    Member since:
    Apr 2013

    Posted 17 Apr 2013 Link to this post


    How can i setup the Label Format in RadPieChart?

  2. Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 19 Apr 2013 Link to this post

    Hi Richard,

    You can use the PieSeries.LabelDefinitions property to specify a ChartSeriesLabelDefinition. By default the RadPieChart shows the percentage of the data point in the label. You can add additional information to the label by using the Format property of the ChartSeriesLabelDefinition like this:
    <telerik:ChartSeriesLabelDefinition Format="Percentage: {0}"/>

    This will result in labels displaying like so: Percentage: 45%

    For more advanced scenarios, you can use the Template property: 

            <TextBlock Text="{Binding DataItem.Name}"/>
            <TextBlock Text="{Binding Value, StringFormat='Cost {0:C0}'}"/>
            <TextBlock Text="{Binding Percent, StringFormat='{0:F2} %'}"/>

    The DataContext of the Template is of type PieDataPoint. Apart from the value and calculated percentage, the other useful property is DataItem. It gives you a reference to underlying data item in the ItemsSource.

    I hope this helps.

    Kind regards,
    Petar Kirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top