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

Pie Chart with two information in the label

1 Answer 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Gifer
Top achievements
Rank 1
Gifer asked on 06 Nov 2010, 02:58 AM
Hi,

I would like to visualize a 2d pie chart with two labels. Basically I want each slice to have a label with two different information.

For example I want to show the percentage and the Name. Right now I'm only able to show either one.
This is the code

 

 

SeriesMapping seriesMapping = new SeriesMapping()

 

{

ChartArea = chartArea,

 

};

 

 

PieSeriesDefinition pie = new PieSeriesDefinition();

 

pie.RadiusFactor = 0.5;

pie.ShowItemToolTips =

 

true;

 

pie.LabelSettings.ShowConnectors =

 

true;

 

pie.LabelSettings.ShowZeroValueLabels =

 

false;

 

pie.LabelSettings.SpiderModeEnabled =

 

true;

 

 

seriesMapping.SeriesDefinition = pie;

 

seriesMapping.ItemMappings.Add(

 

new ItemMapping("Value", DataPointMember.YValue));

 

seriesMapping.ItemMappings.Add(

 

new ItemMapping("Name", DataPointMember.Label));

 

 

seriesMapping.ChartArea.EnableAnimations =

 

false;

 

 

pieChart.SeriesMappings.Add(seriesMapping);

 

pieChart.ItemsSource = items;

 

 

}

Thank you

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 10 Nov 2010, 02:03 PM
Hello Fernando,

To be able to show Percentage and Name as Pie Item's Label here is what you can do:
Use Format Expression (http://www.telerik.com/help/silverlight/radchart-features-format-expressions.html) and specifically the #DATAITEM token and set Percentage and Name for Series Items Labels of the Pie like this:
seriesMapping.SeriesDefinition.ItemLabelFormat = "#% - #DATAITEM.Name";
#% defines the Percentage of the Pie's slice and Name is the name of the property you need to show in the label.

All the best,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Gifer
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or