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

Pie Chart Labels/Values

4 Answers 346 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.
Xavier Soares
Top achievements
Rank 2
Xavier Soares asked on 15 Sep 2008, 03:41 PM

Hello,

Is it possible in pie chart show the slice name and correspondent value?

I only can show or one or other.

Thank you.
LM

4 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 16 Sep 2008, 06:26 AM
Hi Luis,

Thank you for contacting us. There are two solutions to the problem:
  1. Handle the ItemDataBound event and set the corresponding label's text to the one you want. Through the event arguments you can access the data item that is currently binding to the ChartItem.
  2. If your data source is DataTable, create a new expression column, which concatenates the label and the value. Then use this column as source for the pie chart's labels.
Should you need further assistance, do not hestitate to write us back.

Regards,
Evtim
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Xavier Soares
Top achievements
Rank 2
answered on 16 Sep 2008, 09:43 AM
Hello,

The second option don't seems to help because I need to show the name and the corresponding percentage, not the value.

Can you give an hand with the first option?

By the way, the sample that is in the RadChart help is what I need (Mailbox Space in Rad Chart Basics).

Thank You.
LM
0
Dwight
Telerik team
answered on 19 Sep 2008, 11:38 AM
Hello Luis,

This approach requires you to handle the ItemDataBound event. Here is a sample handler method:
void radChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e) 
    DataRowView row = e.DataItem as DataRowView; 
    e.SeriesItem.Label.TextBlock.Text = string.Format("{0}, value = #%", row["Text"]); 
Note, that the current example assumes the data source is DataTable and the data item supplied is DataRowView. The #% in the string tells the chart that it should put percentage at that place in the string.

Regards,
Evtim
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Xavier Soares
Top achievements
Rank 2
answered on 19 Sep 2008, 12:58 PM
Worked! Thank You.

LM
Tags
Chart (obsolete as of Q1 2013)
Asked by
Xavier Soares
Top achievements
Rank 2
Answers by
Dwight
Telerik team
Xavier Soares
Top achievements
Rank 2
Share this question
or