Zedgraph, a powerful open-source chart control supporting. net, is the latest version.
New update as of 28-nov-2007Version 5.1.4 + 4.6.4
Official homepage: http://zedgraph.org/
Sourceforg home page: http://zedgraph.sourceforge.net/
5. x supports. net2.0, and 4. x supports. net1.1. For personal reasons, the version used here is 5.1.1, and the method is similar.
Because it is open-source, a lot of code can be found in the sample, but there is no linechart addition method in the example. By referring to the method of adding values to barchart In the example, a feasible solution is provided here.
All the elements in zedgraph are drawn by using the GDI + technique. In fact, we need to create several textobject files and add them to the chart. Before that, we need to find the position of each vertex.
The practice is also very simple.
Masterpane. axischange (g );
Add the following code:
Int ord = 0;
Foreach (curveitem mycurve in mypane. curvelist)
{
Lineitem line = curve as lineitem;
If (line! = NULL)
{
Ipointlist points = mycurve. Points;
For (INT I = 0; I <points. Count; I ++)
{
Double xval = points [I]. X;
Double yval = points [I]. Y;
String lab = yval. tostring ("0.00") + "% ";
Textobj text = new textobj (lab, (float) xval, (float) yval * 1.01 );
Text. Location. coordinateframe = coordtype. axisxyscale;
Text. fontspec. size = 10;
Text. Location. alignh = alignh. Center;
Text. Location. alignv = alignv. bottom;
Text. fontspec. Border. isvisible = false;
Text. fontspec. angle = 0;
Text. fontspec. Fill. isvisible = false;
Mypane. graphobjlist. Add (text );
}
}
Ord ++;
}
Note:
- In earlier versions of zedgraph, the name of textobj is textitem.
- Masterpane. axischange (g); the statement in earlier versions is base. zedgraphcontrol. axischange ();
- The current version type of curve. Points is ipointlist, and the early version is pointpairlist.
- In this Code, (float) yval * 1.01 is used to generate an upward offset, because you do not know the specific height of the Y axis, if strong displacement is used, the offset effect cannot be reached because the Y axis scale is too short.
Last: