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

How to programatically set the Legend on a PIE Chart

3 Answers 210 Views
Chart
This is a migrated thread and some comments may be shown as answers.
bill
Top achievements
Rank 1
bill asked on 16 Mar 2009, 09:32 AM
How would you programatically create chartlegened itmes for a pie chart and be able to associate them with a specific chart such that it matches the colors of the specific chart.   I am able to programatically create ChartLegendItems and add them to the chart i.e.
chart1.defaultview.chartlegend.Items.Add(chartlegenditem1) ... but the items show up with white background.  How do I associate the chartlegenditems with the chart so that the colors match?


3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 19 Mar 2009, 03:21 PM
Hello Bill,

Actually, you shouldn't have to do this. The legend items are controlled by the SeriesDefinition.LegendDisplayMode property. For pie and doughnut series definition this property is set LegendDisplayMode.DataPointLabel by default, so for each slice there is an item in the legend and this item is automatically styled by RadChart to match the style of the corresponding chart item.

Regards,
Ves
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kevin
Top achievements
Rank 2
answered on 02 Apr 2009, 09:53 PM
I need to do something similar. I know how to get the colors to match up with each other, but I'd like to be able to choose what those colors are. Is there any way to do this for the pie chart?
0
Vladimir Milev
Telerik team
answered on 06 Apr 2009, 03:30 PM
Hi Kevin,

As suggested in the support ticket you opened, the best approach is to use the MVVM pattern which is heavily utilized in silverlight applications. We have prepared an online example which should help users trying to implement it with RadChart for Silverlight.

Regards,
Vladimir Milev
Tags
Chart
Asked by
bill
Top achievements
Rank 1
Answers by
Ves
Telerik team
Kevin
Top achievements
Rank 2
Vladimir Milev
Telerik team
Share this question
or