2D Pie Chart Sample Code

4 posts, 1 answers
  1. shahab
    shahab avatar
    22 posts
    Member since:
    Oct 2012

    Posted 13 Jun 2009 Link to this post

    Hi Can anyone please guide me to a creating a simple pie chart with legend in the code behind in C# or have some code.

    Basically I have a datatable which returns the following data and would like to draw a pei chart:

    Exercise Type A: 30
    Exercise Type B : 60
    Exercise Type C : 10

    All the examples I have seen so far is for bar graphs.

    Many Thanks
  2. Answer
    Ves avatar
    2870 posts

    Posted 17 Jun 2009 Link to this post

    Hi Shahab,

    The type of the chart series created is defined by an object deriving from SeriesDefinition. In this case, you need to use a PieSeriesDefinition. You can set the DefaultSeriesDefinition property of RadChart before assigning its ItemsSource property:

    RadChart1.DefaultSeriesDefinition = new PieSeriesDefinition();

    This will point that you need any series created within the chart to be a pie series. If you need to show the exercise type value in the legend, you can take advantage of the SeriesMapping mechanism in RadChart. I have attached a small example showing this.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
  4. dCODE
    dCODE avatar
    18 posts
    Member since:
    Jan 2010

    Posted 06 Jan 2010 Link to this post

    Hi i need to clarify my doubt. whether animation is possible for this clicking the pie item in chart area. For example the section of the pie being clicked on is pulled out or exploded  from the chart when clicking on it

    the below is my chart am using. if so tel me how to do it else plz give me a sample for doing like this



    telerikChart:RadChart Name="Chart" Height="500" Margin="10,0,10,0" HorizontalAlignment="Stretch" DockPanel.Dock="Top">








    <telerikCharting:ChartTitle Content="Report" HorizontalAlignment="Center"/>






    <telerikCharting:ChartLegend x:Name="ChartLegend" UseAutoGeneratedItems="True"/>






    <telerikCharting:ChartArea Name="ChartArea" LegendName="ChartLegend" Margin="20" ItemClick="ChartArea_ChartItemClick" ClipToBounds="False">






    <telerikCharting:PieSeriesDefinition DefaultLabelFormat="p" ShowItemToolTips="True">






    <telerikCharting:DataPoint YValue="20" LegendLabel="Example 1" />


    <telerikCharting:DataPoint YValue="10" LegendLabel="Example 2" />


    <telerikCharting:DataPoint YValue="30" LegendLabel="Example 3" />


    <telerikCharting:DataPoint YValue="40" LegendLabel="Example 4" />
















  5. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 06 Jan 2010 Link to this post

    Hi dCODE,

    The current version of the control does not support exploding of pie slices so it will not be possible to achieve the desired effect. This feature is in our TODO list and will be added for one of the future releases of the control.

    All the best,
    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.
Back to Top