We've already completed the custom class for pie and bar graphs, and we're going to apply these classes here.
Use Vs.net to create a new Web application called Insight_cs and add it to the Insight project just now. Delete the default WebForm1.aspx file, and create a new file named Saleschart.aspx.
Open this file and in code mode, replace the first line with the following:
<%@ Page contenttype= "Image/gif" language= "C #" autoeventwireup= "false" codebehind= "SalesChart.aspx.cs" inherits= " Insight_cs.
Saleschart "%> opens the file SalesChart.aspx.cs, where the code looks like this: using System;
Using System.Data;
Using System.Web;
Using System.IO;
Using System.Data.SqlClient; Using Insight_cs. webcharts;//This is a custom name space namespace Insight_cs {public class SalesChart:System.Web.UI.Page {public Saleschart () {page.in
it + = new System.EventHandler (Page_Init); The private void Page_Load (object sender, System.EventArgs e) {//Gets data from the database for drawing String sql = "Select" + "Year" (Sa.ord_date) As [year], "+" SUM (sa.qty) as [qty] "+" + "sales sa" + "inner Join stores St. on (sa.stor_id = st.stor_id)" + "GROUP B
Y "+" Year (sa.ord_date) "+" ORDER By "+" [year] "; String connectstring = "Password=ben;" User Id=sa;
Database=pubs;data Source=localhost ";
SqlDataAdapter da = new SqlDataAdapter (sql,connectstring);
DataSet ds = new DataSet (); int rows = da.
Fill (ds, "ChartData"); Sets the type of the production graph (pie or bar) String type = ""; if (null==request["type"]) {type = "PIE";} else {type = request["type"]. ToString ().
ToUpper ();
//Set Figure size int width = 0;
if (null==request["width"]) {width = = = = Else {width = Convert.ToInt32 (request["width")} int height = 0; if (null==request["height") {height = = = = Else {height = Convert.ToInt32 (request["height"));//Set chart title string title
= ""; if (null!=request["title"]) {title = request["title"].
ToString ();
} string subtitle = ""; if (null!=request["subtitle"]) {subtitle = request["subtitle"].
ToString (); } if (0<rows) {switch (type) {case "PIE": piechart pc = new Piechart (), PC.
Render (Title,subtitle,width,height,ds,response.outputstream);
Break
Case "BAR": barchart BC = new Barchart (); Bc.
Render (Title,subtitle,width,height,ds,response.outputstream);
Break
Default:break; }} private void Page_Init (object sender, EventArgs e) {////Codegen:this call was required by the ASP.net Web Form De
Signer.
InitializeComponent (); #region Web Form Designer GenerateD-code///<summary>///Required method for Designer support-do not modify///the contents of it with T
He code Editor. </summary> private void InitializeComponent () {this. Load + = new System.EventHandler (this.
Page_Load);
} #endregion}}
The above code does not have any difficulty, here does not do the analysis.