RSS Feed
RSS Feed
Search
AddThis Feed Button
Bookmark and Share





<%@ Page %>

Creating Bar and Pie Charts in ASP.NET

Introduction

.NET provides many drawing classes via System.Drawing namespace. Prior to ASP.NET it was difficult for an ASP developer to create and emit images (jpg, gif etc.) to the browser at run time. Combining ASP.NET and System.Drawing one can develop attractive charts. This code sample shows how to create bar and pie charts using the technique mentioned above.

What the sample application does?

The sample application draws bar and pie charts for hours spend per day on some fictitious task. The data for X-axis (days) as well as Y-axis (hrs. spend) is stored in an array. The application draws bar and pie graph for the data and saves it to Response.OutputStream. The application consists of three files:
  • BarChart.aspx: This file contains code that generates bar chart for given values
  • PieChart.aspx: This file contains code that generates pie chart for given values
  • ChartHost.aspx: This file contains two image web controls displaying bar and pie chart.

Sample Run

How to run the sample

  • Create a new web application in VS.NET called AspNetCharts
  • Unzip supplied code files in the project folder
  • Add the files mentioned above in the project
  • Run ChartHost.aspx


Associated Links
Download Source Code

Posted On : 03 Aug 2002
Current Rating :
Rate This Article :

About the Author
Bipin Joshi
Bipin Joshi is a blogger and writes about Yoga, spirituality and technology. A former Software Consultant by profession he worked for many years with Microsoft technologies such as C, C++, C#, VB, ASP and ASP.NET. Bipin got selected as a Most Valuable Professional (MVP) by Microsoft for six consecutive years before he decided to take a back seat from the mainstream IT to continue his spiritual interests. More details about him can be read here.



Copyright (C) bipinjoshi.net. All rights reserved.
Contact Us
Read Terms Of Use
Hosted By DiscountASP