Step 1: Download zedgraph 4.6 (. NET 1.1)
Step 2:Add zedgraph. dll and zedgraph. Web. DLL to the vs2003.net project.
Step 3:Add zedgraph. Web. DLL to the toolbox
Step 4:Drag the added visualization component
Step 5:Code generated on the ASPX page
<% @ Register tagprefix = "PC3" namespace = "zedgraph. Web" assembly = "zedgraph. Web" %>
<% @ Page Language = "C #" codebehind = "netpictest. aspx. cs" autoeventwireup = "false" inherits = "ws. webs. netpictest" %>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> netpictest </title>
<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "code_language" content = "C #">
<Meta name = "vs_defaultclientscript" content = "JavaScript">
<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<PC3: zedgraphweb id = "zedgraphweb1" runat = "server"> </PC3: zedgraphweb>
</Form>
</Body>
</Html>
Step 6: Aspx. CS code
Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using zedgraph;
Using zedgraph. Web;
Namespace ws. Webs
{
/// <Summary>
/// Summary of netpictest.
/// </Summary>
Public class netpictest: system. Web. UI. Page
{
Protected zedgraph. Web. zedgraphweb zedgraphweb1;
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
}
# Code generated by region web Form Designer
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. Load + = new system. eventhandler (this. page_load );
This. zedgraphweb1.rendergraph + = new zedgraphwebcontroleventhandler (this. onrendergraph );
}
# Endregion
Private void onrendergraph (zedgraphweb zgw, graphics g, masterpane)
{
// Get the graphpane so we can work with it
Graphpane mypane = masterpane [0];
Mypane. Title. Text = "sales statistics ";
Mypane. xaxis. Title. Text = "region ";
Mypane. yaxis. Title. Text = "total sales: RMB ";
Pointpairlist list = new pointpairlist ();
Pointpairlist list2 = new pointpairlist ();
Pointpairlist list3 = new pointpairlist ();
Random Rand = new random ();
For (Double X = 0; x <5; X ++ = 1.0)
{
Double Y = Rand. nextdouble () * 100;
Double y2 = Rand. nextdouble () * 100;
Double Y3 = Rand. nextdouble () * 100;
List. Add (x, y );
List2.add (x, Y2 );
List3.add (x, Y3 );
}
Baritem mycurve = mypane. addbar ("buy", list, color. Blue );
Mycurve. Bar. Fill = New fill (color. Blue, color. White, color. Blue );
Baritem mycurve2 = mypane. addbar ("plaintext", list2, color. Red );
Mycurve2.bar. Fill = New fill (color. Red, color. White, color. Red );
Baritem mycurve3 = mypane. addbar ("Upgrade", list3, color. Green );
Mycurve3.bar. Fill = New fill (color. Green, color. White, color. Green );
Mypane. xaxis. majortic. isbetweenlabels = true;
String [] labels = {"Domain Name", "host", "Database", "Post Office", "package "};
Mypane. xaxis. Scale. textlabels = labels;
Mypane. xaxis. type = axistype. text;
Mypane. Fill = New fill (color. White, color. fromargb (200,200,255), 45.0f );
Mypane. Chart. Fill = New fill (color. White, color. lightgoldenrodyellow, 45.0f );
Masterpane. axischange (g );
}
}
}
Step 7:Create the default image save path folder zedgraphimages in the project
The final effect is as follows: