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

2D Pie Chart Sample Code

3 Answers 323 Views
Chart
This is a migrated thread and some comments may be shown as answers.
shahab
Top achievements
Rank 1
shahab asked on 13 Jun 2009, 11:21 AM
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
shahab

3 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 17 Jun 2009, 08:48 AM
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,
Ves
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.
0
dCODE
Top achievements
Rank 1
answered on 06 Jan 2010, 08:45 AM

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">

 

<telerikChart:RadChart.DefaultView>

 

<telerikCharting:ChartDefaultView>

 

<telerikCharting:ChartDefaultView.ChartTitle>

 

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

 

</telerikCharting:ChartDefaultView.ChartTitle>

 

<telerikCharting:ChartDefaultView.ChartLegend>

 

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

 

</telerikCharting:ChartDefaultView.ChartLegend>

 

<telerikCharting:ChartDefaultView.ChartArea>

 

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

 

<telerikCharting:ChartArea.DataSeries>
<telerikCharting:DataSeries>

 

<telerikCharting:DataSeries.Definition>

 

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

 

</telerikCharting:PieSeriesDefinition>

 

</telerikCharting:DataSeries.Definition>

 

<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" />

 

</telerikCharting:DataSeries>
</telerikCharting:ChartArea.DataSeries>

 

</telerikCharting:ChartArea>

 

</telerikCharting:ChartDefaultView.ChartArea>

 

</telerikCharting:ChartDefaultView>

 

</telerikChart:RadChart.DefaultView>
</telerikChart:RadChart>

 

 

 

 

 

0
Giuseppe
Telerik team
answered on 06 Jan 2010, 12:03 PM
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,
Manuel
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.
Tags
Chart
Asked by
shahab
Top achievements
Rank 1
Answers by
Ves
Telerik team
dCODE
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or