.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
satyapriyanayak
SP
abhays
Sasi Prabhu

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

.NET Framework 3.5 ASP.Net Chart Control Example

Posted By:Pankaj Mishra       Posted Date: November 30, 2008    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  
 

Microsoft releases its most awaited Chart control integrated with .NET Framework3.5 with service pack1. Now you can build your web or windows application with charting features without any third party control. That means you need not to pay extra money to buy third party charting software.

You can download the Charting API from here.

After downloading, Install this API, but make sure you should have .NET Framework 3.5 with service pack 1 installed already.

Once you have installed this ASP.Net Charting API in your system, you can add ASP.Net Chart assembly to your Visual Studio 2008 toolbox as shown below:



Right click on the toolbox ->Choose Items->.NET Framework Component tab Browse Button -> Locate your Chart API(:\Program Files\Microsoft Chart Controls\Assemblies)-> Select "System.Web.DataVisualization.dll" then press "ok" Button.
 
Now you have added Chart Component in your toolbox


 
Now you are ready to create your first chart application. Just drag your Chart component from your toolbox into you web page.  After adding your chart control to your web page your page should look like this.


 
Add System.Web.UI.DataVisualization.Charting Namespace like this.

using System.Web.UI.DataVisualization.Charting;

Now you aspx.cs code should look like this in your page_Load event wirte this code. Belo code sample will create 3d Bar chat with sample data.

 

protected void Page_Load(object sender, EventArgs e)
{
        //Create some dummy Data

Random random = new Random();

for (int pointIndex = 0; pointIndex < 10; pointIndex++)

{

Chart1.Series["Series1"].Points.AddY(random.Next(20, 100));

}

//Set the chart type

Chart1.Series["Series1"].ChartType = SeriesChartType.Bar;

// Set the bar width

Chart1.Series["Series1"]["PointWidth"] = "0.5";

// Show data points labels

Chart1.Series["Series1"].IsValueShownAsLabel = true;

// Set data points label style

Chart1.Series["Series1"]["BarLabelStyle"] = "Center";

// Show chart as 3D

Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;

// Draw chart as 3D Cylinder

Chart1.Series["Series1"]["DrawingStyle"] = "Cylinder";

}

Once you run your application, your output browser will look like this:

Reference Site MSDN
 
Cheers
Pankaj

 Subscribe to Articles

     

Further Readings:

Responses
Author: Guru         Company URL:
Posted Date: December 02, 2008

Charting Control
Author: centade         Company URL: http://www.dotnetspark.com
Posted Date: August 09, 2013

Nice Chart Control! We can achieve this by using a WinForms Chart control too.
http://www.kettic.com/

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend