Zedgraph is an open-source control that provides user controls and Web controls. It can create 2D linear graphs, bar charts, and pie charts. This paper introduces the main types and multi-dimensional data of zedgraph, discusses how to apply the zedgraph control to the multi-dimensional data graph display, and uses zedgraph to visualize multi-dimensional data easily and easily.
1. Use zedgraph to create a column chart
1.1 prepare zedgraph-related controls
This article focuses on the use of zedgraph on the web page. The programming language used is C #. To use the zebgraph control on the web page, the zebgraph. dll and zedgraph. Wed. dll assembly files are required.
Currently, many versions of the zedgraph control are available. Since my machine's system is WINXP, vs version is 2005, and the Environment is Framework 2.0, the zedgraph version I use is a VESION-514_464. As for the compatibility between the zedgraph version and the Framework version, I did not bother to discuss it, mainly because the time was too short to come, so please be considerate.
Since the zedgraph control code is open-source, many websites provide download services. (You only need to open your browser, enter Baidu, Google, and other search engine pages, enter "zedgraph download" in the input box, and then click the search button or press the Enter key, the page displays a lot of information about zedgraph download. At last, you only need to download it from the correct page .)
1.1 create and create a test website
Create a project file
Steps:
1. Open the vs2005 Development Tool
2. Click new> website
3. Select the desired solution template, select the Project Storage path, enter the project name, and click OK.
The result is as follows:
Configure the environment (add the zedgraph component)
1. Add the zedgraph control to the toolbar.
Right-click the control toolbox and choose> select items> COM components> zedgraph. dll and zedgraph. Web. DLL files. Click OK.
The corresponding icon appears in the toolbox.
2. Add the zedgraphweb control to the default. aspx page. The result is as follows:
3. Create a folder named images in the home directory.
4. Add zedgraph. dll and zedgraph. Web. DLL to the bin directory as follows:
Encoding
1. Set simple attributes in the attribute Column
Height (control height): 486
Width: 800
Tmpimageduration (interval for generating temporary files): 0
Renderedimagepath (path for generating temporary files ):~ /Images/
2. subscribe to the rendergraph event of the zedgraphweb control in the page loading event
3. zedgraphweb_rendergraph event Encoding
.
.
.
// Coordinate settings are omitted
// Simulate data
Random Rand = new random ();
Pointpairlist pointlist = new pointpairlist ();
Pointpairlist pointlist2 = new pointpairlist ();
Pointpairlist pointlist3 = new pointpairlist ();
For (INT I = 0; I <7; I ++ ){
// If X-ray is a data size, you need to test the I value.
Pointlist. Add (I, Rand. nextdouble () * 100 );
Pointlist2.add (I, Rand. nextdouble () * 100 );
Pointlist3.add (I, Rand. nextdouble () * 100 );
}
// Add a column chart
Graphpane. addbar ("new customer", pointlist, color. Black). Bar. Fill = New fill (color. Red, color. White, color. Red, 0f );
Graphpane. addbar ("old customer", pointlist2, color. Black). Bar. Fill = New fill (color. Green, color. Yellow, color. Green, 0f );
Graphpane. addbar ("new product", pointlist3, color. Black). Bar. Fill = New fill (color. Blue, color. White, color. Blue, 0f );
// Update the view
Pane. axischange (g );
.
.
.
1.3 run the test website
The result is as follows: