Using the Graph2D Class
The class that I created to encapsulate the graphing class is called Graph2D. There are three required steps to use the class: instantiate the class, add data, and render the graph. The following code snippet shows the bare necessities for creating a graph image that saves to disk. More detail for these methods will be given shortly.C#
Graph2D graph = new Graph2D(); String strFilename; graph.AddPair( "Rick", 50 ); graph.AddPair( "Sam", 60 ); strFilename = graph.Render( Request.MapPath( "" ) );VB
Dim graph as new Graph2D() Dim strFilename as String graph.AddPair("Rick", 50) graph.AddPair("Sam", 60) strFilename = graph.Render(Request.MapPath(""))
The presentation code must use the file name that's returned from the Render() method. The file name can either be assigned to an ASP.NET server object such as Image or ImageButton objects, or output to the HTML stream with a call to the Response.Write() method.
Chapter 10 has a complete reference to the Graph2D class, including the properties that are available with which you can change its appearance.