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

Name the datapoints in the legend for Pie chart

3 Answers 161 Views
Chart
This is a migrated thread and some comments may be shown as answers.
KPK
Top achievements
Rank 1
KPK asked on 11 Sep 2009, 04:08 PM
Hi, I have the following code to bind data to a RadChart, which I am setting to be a 3D PieChart in the C# code.

            RadChart1.SeriesMappings.Clear();

            SeriesMapping mapping = new SeriesMapping();
            mapping.SeriesDefinition = new Pie3DSeriesDefinition();
           
            ItemMapping item = new ItemMapping();
            item.DataPointMember = DataPointMember.YValue;
            item.FieldName = "RedemptionCount";

            mapping.LegendLabel = "Redemptions";
           
            mapping.ItemMappings.Add(item);

            mapping.SeriesDefinition.LegendDisplayMode = LegendDisplayMode.DataPointLabel;
            RadChart1.SeriesMappings.Add(mapping);

            RadChart1.ItemsSource = e.Result;
            RadChart1.DefaultView.ChartTitle.Content = "Redemptions";


The Pie correctly displays Redemptions and the legend lists the corresponding items, but it only says Item 0, Item 1, Item 2.  Each of these items represent a specific Program and should be labeled accordingly.  I am able to obtain the Program Title by doing: e.Result[1].ProgramTitle.ToString().  Doing it this way I need to provide the index of the result to get the program title, so I would be needing a foreach loop to rename each of the existing legend items.

Also, in the Pie Chart the RedemptionCount is displayed next to the slice of the Pie it corresponds to.  if it is possible, can I set the Program Title to display alongside the RedemptionCount in the chart and forego the Legend completely?

On a side note, the colors in the Pie Chart and the Legend (which the controls are autogenerating) do not quite match.  Yellow is being used in the Pie and matches closest to the Orange in the Legend.  There is a light blue in the pie that matches to a darker blue in the legend and the green is more flourescent in the legend.  Is there any reason for this?

Let me know of the best way to assign the values for the Legend labels/names.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 15 Sep 2009, 08:17 AM
Hi KPK,

Please, find the answer to your question in your other post.

All the best,
Evtim
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tony Ser
Top achievements
Rank 1
answered on 27 Aug 2010, 07:47 PM
Could you please post a link to that post?  I am also curious in the answer.

Thanks!
0
Ves
Telerik team
answered on 01 Sep 2010, 02:30 PM
Hi Tony,

Here is our reply to KPK's last question:

You need add new ItemMapping, which defines the mapping for the legend item:
            ItemMapping item = new ItemMapping();
            item.DataPointMember = DataPointMember.LegendLabel;
            item.FieldName = "ProgramTitle";

To add the LegendLabel text to the Pie label, use:

mapping.SeriesDefinition = new Pie3DSeriesDefinition() { DefaultLabelFormat = "#LEGENDLABEL #VALUE" };

For more information on the label formats, please, refer to http://www.telerik.com/help/wpf/radchart-features-format-expressions.html


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
Tags
Chart
Asked by
KPK
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Tony Ser
Top achievements
Rank 1
Ves
Telerik team
Share this question
or