PieChart Example in ASP.NET using C#

PieChart Example in ASP.NET using C#


Posted in : ASP.Net Posted on : December 2, 2010 at 6:27 PM Comments : [ 0 ]

In this article we will introduce with PieChart control in ASP.NET using C#.

PieChart Example in ASP.NET using C#

PieChart in ASP.NET is used for Data Visualization. Piechart is just like a circle. This circle is divided by percentage of the value. You can make 3D PieChart in ASP.NET. You can bind data using SQLDataSource and other data source .
In this example we make a 3D PieChart and bind data with SQLDataSource.

PieChart.aspx (Design Page):

PieChart.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" 
AutoEventWireup="true"
CodeFile="PieChart.aspx.cs" Inherits="PieChart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div>
<h2 style="color: Green">
Pie Chart in ASP.NET 4, C#</h2>
<asp:Chart ID="Chart1" runat="server" BackColor="DarkCyan" BackGradientStyle="Center"
DataSourceID="SqlDataSource1" Height="498px" Palette="SemiTransparent" Width="581px">
<Series>
<asp:Series ChartType="Pie" Legend="Legend1" Name="Series1" XValueMember="CountryName"
YValueMembers="Population">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea AlignmentOrientation="All" BackColor="Black" Name="ChartArea1">
<AxisY IsLabelAutoFit="False" TextOrientation="Rotated90" Title="---Population---"
TitleFont="Microsoft Sans Serif, 10pt, style=Bold">
<LabelStyle Angle="90" Font="Microsoft Sans Serif, 10pt, style=Bold" />
</AxisY>
<AxisX IsLabelAutoFit="False" TextOrientation="Rotated90" 
Title="---Country---" TitleFont="Microsoft Sans Serif, 10pt, style=Bold">
<LabelStyle Angle="90" Font="Microsoft Sans Serif, 10pt, style=Bold" />
</AxisX>
<Area3DStyle Enable3D="True" Inclination="45" Rotation="90" 
LightStyle="Realistic" />
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend LegendStyle="Column" Name="Legend1">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Font="Microsoft Sans Serif, 16pt, style=Bold" Name="Title1" 
Text="---Population Survay 2010---">
</asp:Title>
</Titles>
</asp:Chart>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ChartDatabaseConnectionString %>"
SelectCommand="SELECT * FROM [ChartPopulation]"></asp:SqlDataSource>
<br />
</div>
</asp:Content>

Output:

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics