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

Custom Legend in Pie Chart

2 Answers 151 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arvind
Top achievements
Rank 1
Arvind asked on 04 Aug 2010, 10:09 AM
Hi,
   The following is the code I use.  I have attached the pie chart generated by this code.

 

ICollection<PieChartSeries> pieChartList = new List<PieChartSeries>();

 

 

GeneratePieChart generatePieChart = new GeneratePieChart();

 

pieChartList = generatePieChart.GenerateChartSeries();

radChart1.DataManager.DataSource = pieChartList;

radChart1.DataManager.LabelsColumn =

"ItemName";

 

radChart1.DataManager.ValuesXColumn =

"Value";

 

radChart1.IntelligentLabelsEnabled =

true;

 

radChart1.DataBind();

radChart1.Series[0].Name =

"LegendName";

 

radChart1.Series[0].Appearance.LegendDisplayMode =

ChartSeriesLegendDisplayMode.ItemLabels;

 

radChart1.Update();


The legends are not displaying the values of the LegendName property of the colloection pieChartList. 
The LegendName property will have some names like Arvind, Robin, Kumar, Mark, etc...

Now the radChart is taking the legends as the radChart1.DataManager.LabelsColumnradChart1.DataManager.LabelsColumn's data (ItemName). Is it possible to display a different text for the legend (It should be other than the ItemName)?

In the above code I am using the line
radChart1.Series[0].Name = "LegendName";

Does it have any significance?

Regards,
Arvind Robin Kumar.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 09 Aug 2010, 08:49 AM
Hello Arvind,

You can wire the ItemDataBound event of RadChart. In the event handler you can set the Name property of each individual ChartSeriesItem -- this is the value which will appear in the legend. The event arguments will hold references to the ChartSeriesItem, ChartSeries and the underlying data. It would be similar to what's shown in this blog post, but you need to set the Name property and not the Label's text.

 Setting the Name property of the ChartSeries would not make any difference in this case. The value of ChartSeries.Name is shown in the legend when the ChartSeries.Appearance.LegendDisplayMode is set to ChartSeriesLegendDisplayMode.SeriesName.

Kind regards,
Ves
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
0
André Paulo
Top achievements
Rank 1
answered on 10 Aug 2010, 03:14 PM
i'll put my problem in other topic.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Arvind
Top achievements
Rank 1
Answers by
Ves
Telerik team
André Paulo
Top achievements
Rank 1
Share this question
or