Graph Control Under. Net --- basic usage of nplot
Basic usage of nplot
Chart controls are always hard to find, especially free and powerful. Nplot is very rare. NET platform chart controls, can do a variety of graphs, bar chart, pie chart, scatter chart, stock chart, and so on, and it is free and open-source, use is also very consistentProgramHabits of members. The only drawback is that documents are hard to find and read. Through Reading its documents and the example ProgramSource codeThe basic concepts of nplot are as follows:
Nplot namespaces include nplot and nplot. bitmap, nplot. web, nplot. web. design, nplot. windows, etc. Among them, the core class that manages various charts belongs to the nplot namespace, nplot. bitmap manages bitmap, nplot. web, nplot. web. design and nplot. windows can be considered as a nplot chart container on web form and Windows form (plotsurface2d ). These containers can be dragged to form or in other containers.
To apply the nplot control in an application, add the downloaded nplot. dll to the. Net project. And add it to the Toolbox tray. Add method: Right-click the toolbox and select "select item". The "select toolbox item" dialog box appears. net frameworks component, select Browse, and find nplot. DLL is added to the toolbox. The nplot control appears in the toolbox. When designing the application interface, you can drag it into the application interface.CodeAutomatically create a plotsurface2d object.
The plotsurface2d object is the nplot chart container. All the chart graphics, coordinates, titles (all inherit the idrawable Interface) and other information can be added to plotsurface2d. Plotsurface2d has a very important method: Add. You can add plotsurface2d objects to various chart charts, coordinates, and titles by adding them. Plot: is the control name and introduces space: Using nplot;
We can use the following simple code example to understand the basic usage of nplot:
Public void plotline ()
{
// --- Ploy ---
Plot. Clear ();
// --- Grid code ---
Grid mygrid = new grid ();
Mygrid. horizontalgridtype = grid. gridtype. None;
Mygrid. verticalgridtype = grid. gridtype. Fine;
Plot. Add (mygrid );
Plot. Title = "test ";
Stepplot line = new stepplot ();
Line. Pen = new pen (color. Red, 1 );
Line. ordinatedata = new int [] {0, 1, 0, 1, 1, 0 };
Line. hideverticalsegments = false;
Plot. Add (line );
Plot. Refresh ();
Return;
}
Both the Grid Object and stepplot object are objects in the nplot namespace and both inherit from nplot. idrawable, which can be used as plotsurface2d. the add function is called. Drawing in nplot is to add various objects, such as grids, coordinates, and graphics, to the plotsurface2d object. Everything is that simple!
Nplot: http://netcontrols.org/nplot/wiki/index.php? N = Main. Homepage
Nplot Development Documentation: http://www.andrewtheken.com/nplot/
E_mail: kissyougoodby@163.com QQ: 55774088
Public void plotline (double [] X, double [] Y)
{
// --- Ploy ---
Plot. Clear ();
// --- Grid code ---
Grid mygrid = new grid ();
Mygrid. horizontalgridtype = grid. gridtype. None;
Mygrid. verticalgridtype = grid. gridtype. Fine;
Plot. Add (mygrid );
Plot. Title = "×××× ";
Lineplot Lp = new lineplot ();
//// Assign a value to the abscissa
LP. abscissadata = x; // New Double [] {0, 25,125 };
//// Assign the ordinate Value
LP. ordinatedata = y; // New Double [] {200,200, 0 };
// Stepplot line = new stepplot ();
// Line. Pen = new pen (color. Red, 1 );
// Line. ordinatedata = new double [] {5.5, 4.0, 1.5, 2.5, 3.5 };
// Line. hideverticalsegments = false;
Plot. Add (LP );
Plot. Refresh ();
Return;
}
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/kissyougoodby/archive/2007/09/21/1794231.aspx