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

Creating a simple Pie Chart

1 Answer 62 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 22 Jun 2010, 04:05 AM
Hi, I'm trying to create a simple Doughnut Pie chart, I was checking the silverlight demo gallery but the code doesn't shows me how to do it because is already done inside class SeriesExtensions.GetUserRadialData.
Could you please tell me how to create manually this kind of chart?

For example I have these categories with values:

Apples, 59
Oranges, 30
Lemon, 40

I need to represent these values with a legend, series and titles.
Thank you very much.

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 22 Jun 2010, 04:54 PM
Hello Chris,

You can achieve the desired functionality like this:
DataSeries series = new DataSeries();
series.Definition = new DoughnutSeriesDefinition();
  
series.Add(new DataPoint(59) { LegendLabel = "Apples" });
series.Add(new DataPoint(30) { LegendLabel = "Oranges" });
series.Add(new DataPoint(40) { LegendLabel = "Lemons" });
  
RadChart1.DefaultView.ChartArea.DataSeries.Add(series);
RadChart1.DefaultView.ChartTitle.Content = "Chart Title";

Also, you can find more information on populating the chart control with data here (the DataPoint / DataSeries objects work in the same way for all series types, it is the SeriesDefinition that provides the series-specific information).

Hope this helps.


Regards,
Freddie
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
Chris Thierry
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or