This tutorial will teach you how to create an exploded Pie Chart in 2D/3D.

Exploded Pie Chart Tutorial ASP.NET 4.0

This tutorial will show you how to create an exploded Pie Chart and how to control
its elements through C# Code Behind.

Overview

1. Create The Chart and Setup The Datapoints

2. Add Button Controls to our form

3. Write the button Controls’ Code

Create the Chart and Setup the Datapoints

1. Start by Creating an Empty ASP.NET Web Application

2. Add a Web Form Named Default.aspx

3. Now Add a Reference to System.Web.DataVisualization like we did in a previous example

4. Add a Pie Chart to the Form in Design View mine is named Chart2

5. Go into the Code View and Paste this code into your ChartAreas code

Add Button Controls to your Form

1. Go Back to the Design View and Drag 5 Button Controls from the Toolbar onto the Form

2. Name the buttons btn1, btn2, btn3, btn4, and btn5 and have their Text Property be set to 1,2,3,4,5 respectively
*Note I also made my Chart 3D but it is not a required step*

Chart5-1

3. This is what it should look like when you have completed adding and editing the buttons

Add the Button Controls’ Code
1. While still in the Design view double click on all of the buttons to open up each buttons code space

2. At the top of the Project add this namespace:

3. Once you have done all 5 buttons and the reference call go into the Code View and Paste this Code into each
Button_Click event Call in order. This code will change the “Exploded” property of a piece of the chart to true
which will make it act like it is selected. When you click on a different button it will issue a postback
to the website which will reset all of the variables to false making it so you can only have one selected at a time.

4. This Code will change the item based on what you clicked to be exploded(popped out)

Conclusion

This tutorial taught us how to create an Advanced 3D Pie Chart and how to create controls to use that Pie Chart.
This is a good start on editing advanced Charts through code but there are many more properties that can be changed
and many more ways to do so.

Download Source Files