Creating a simple Pie Chart

2 posts, 0 answers
  1. Chris Thierry
    Chris Thierry avatar
    138 posts
    Member since:
    Jun 2010

    Posted 21 Jun 2010 Link to this post

    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.
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 22 Jun 2010 Link to this post

    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
  3. DevCraft banner
Back to Top