ASP.NET drawing full Raiders (below)

xiaoxiao2021-03-06  49

http://www.aspcool.com/lanmu/browse1.asp?ID=818&bbsuser=aspnet Author: bben_h www.ASPCool.com Time: 2002-1-13 16:07:13 Views: 8378

We have completed the custom class of the pie chart and bar chart in front, and we will apply these classes. Use VS.Net to create a web application called Insight_CS and add it to the INSIGHT project. Delete the default WebForm1.aspx file, create a newly called Saleschart.aspx file.

Open this file, replace the first line to: <% @ page contentty = "image / gif" language = "false" codebehind = "false" code = "inherits=" inSight_CS .Saleschart "%> Open the file saleschart.aspx.cs, where the code is as follows: use system; use system.data; use system.web; useing system.io; using system.data.sqlclient; using insight_cs.WebCharts; / / this is a custom namespace namespace Insight_cs {public class SalesChart: System.Web.UI.Page {public SalesChart () {Page.Init = new System.EventHandler (Page_Init);} private void Page_Load (object sender, System .Eventargs e) {// acquire data from the database, used to draw string sql = "SELECT" "year (sa.ord_date) AS [Year]," "SUM (SA.QTY) AS [qty]" "From" "Sales SA" "Inner Join Store ST On (sa.stor_id = st.stor_id)" "GROUP BY" "Year (sa.ord_date)" "Order by" "[Year]" String connectString = "password = Ben; user ID = sa; data source = localhost"; sqldataadapter Da = new SqldataAdapter (SQL, ConnectString); DataSet DS = New DataSet () Int rows = da.fill (DS, "chartdata"); // Set the type of generating diagram (PIE or BAR) String Type = ""; if (null == Request ["]"]) {type = " PIE ";} else {type = request [" type "]. TOSTRING (). TouPper ();} // set map size int width = 0; if (null == request [" width "]) {width = 400 } Else {width = convert.toint32 (Request ["Width"]);

INT height = 0; if (null == request ["height"]) {height = 400;} else {height = convert.toint32 (Request ["Height"]);} // Settings Chart Title String Title = " "; If (null! = Request [" title "]) {title = Request [" title "]. Tostring ();} String subtitle ="; if (null! = Request ["subtitle"]) {subtitle = Request ["subtitle"]. TOSTRING ();} {copy {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 is required by the ASP.NET Web Form Designer. // InitializeComponent ();} #Region Web Form Designer generated code ///

/ // Required Method for Designer Support - Do Not Modify //////////-summary> private () {this.Load = new system.eventhandler (this.page_load);} #endregion}} above code Nothing is difficult, here is not analyzed. In VS.NET, open Insight_CS Solution, right-click "Reference", add "Add Reference", add component file INSIGHT_CS.WEBCHARTS.DLL to make it a Namespace in the project. Below we can browse the results.

转载请注明原文地址:https://www.9cbs.com/read-110173.html

New Post(0)