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

RadPieChart LabelFormat

1 Answer 252 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 17 Apr 2013, 10:06 AM
Hi,

How can i setup the Label Format in RadPieChart?

Thanks

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 19 Apr 2013, 05:22 PM
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: 

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

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.

Tags
ChartView
Asked by
Richard
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or