Simple Application of zedgraph in projects

Source: Internet
Author: User
 Step 1: Download zedgraph 4.6 (. NET 1.1)
Step 2:Add zedgraph. dll and zedgraph. Web. DLL to the 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">
<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 = "">
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<PC3: zedgraphweb id = "zedgraphweb1" runat = "server"> </PC3: zedgraphweb>

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 ); Fill = New fill (color. Red, color. White, color. Red );
Baritem mycurve3 = mypane. addbar ("Upgrade", list3, color. Green ); 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:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.