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

Labels on Pie Chart

5 Answers 139 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Igor
Top achievements
Rank 1
Igor asked on 12 Aug 2012, 10:18 AM
I have a RadPieChart that is bound to an observable collection:

<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

Sort by
0
Victor
Telerik team
answered on 14 Aug 2012, 12:02 PM
Hi Igor,

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.

Greetings,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Igor
Top achievements
Rank 1
answered on 14 Aug 2012, 12:23 PM
Thanks but I do not get how to use it. In the documentation there is (I suppose I should put it in the RadPieChart element content)

<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. 


0
Victor
Telerik team
answered on 15 Aug 2012, 07:16 AM
Hello Igor,

Thanks for writing.
The label definitions are in this namespace:

xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
Also please rebuild your project and upgrade to the latest release in order to be sure that the label definitions feature is present in the assemblies that you are using.

Kind regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Igor
Top achievements
Rank 1
answered on 15 Aug 2012, 07:25 AM
I am using the latest version (2012.2.801.2040) from the start, I cleaned and rebuilt the solution and it did not help. When I paste the label definition to the RadPieChart the complirer says

A value of type 'ChartSeriesLabelDefinition' cannot be added to a collection or dictionary of type 'PresenterCollection`1'.

Could you please attach a complete example? 

0
Accepted
Victor
Telerik team
answered on 15 Aug 2012, 07:34 AM
Hello Igor,

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>
Please write again if you have other questions.

Kind regards,
Victor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Igor
Top achievements
Rank 1
Answers by
Victor
Telerik team
Igor
Top achievements
Rank 1
Share this question
or