<
chart:RadPieChart
Palette
=
"Warm"
x:Name
=
"incomesChart"
>
<
chart:PieSeries
ShowLabels
=
"True"
LabelTemplate
=
"{StaticResource LabelTemplate}"
ValueBinding
=
"Sum"
ItemsSource
=
"{Binding IncomeStats}"
>
</
chart:PieSeries
>
</
chart:RadPieChart
>
The class that is bound to the chart is called StatDetailViewModel and consists of double Sum used in the chart and string Category that I want to show as Labels. My LabelTemplate is
<
DataTemplate
x:Key
=
"LabelTemplate"
>
<
TextBlock
Text
=
"{Binding}"
Foreground
=
"Red"
/>
</DataTemplate>
This template shows the percentage values as Labels in red. I expected that the value sent to this DataTemplate would be my StatDetailViewModel class and not the percentage.
So how do I shows a specific property from the bound class as Label? (string Category in StatDetailViewModel in this case).
5 Answers, 1 is accepted
Thank you for writing.
You need to use the LabelDefinitions property of the chart series. Currently the online help is not updated so please have a look at the attached file. You need to read the Label Definitions article under the Series folder.
Please write again if you need further assistance.
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
<
telerikChart:ChartSeriesLabelDefinition
Binding
=
"Text"
/>
but there is no info what telerikChart is. Is it clr-namespace:Telerik.Charting;assembly=Telerik.Windows.Controls.Chart or clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart? Neither of them shows
ChartSeriesLabelDefinition
in IntelliSense. Thanks for writing.
The label definitions are in this namespace:
xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
Kind regards,
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
A value of type 'ChartSeriesLabelDefinition' cannot be added to a collection or dictionary of type 'PresenterCollection`1'.
Could you please attach a complete example?
When you read the introduction of the help article for the label definitions you will notice that the all series have a LabelDefinitions property which is a collection. You need to put each label definition you define inside this collection. Since you are using the pie series, you need to do this:
<
telerikChart:RadPieChart
>
<
telerikChart:PieSeries
>
<
telerikChart:PieSeries.LabelDefinitions
>
<
telerikChart:ChartSeriesLabelDefinition
/>
</
telerikChart:PieSeries.LabelDefinitions
>
</
telerikChart:PieSeries
>
</
telerikChart:RadPieChart
>
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.