.jpgraph Introduction to open source projects
jpgraph is an object-oriented graphics creation library. It can be used to generate histograms, pie charts, Gantt charts, mesh charts and other commonly used to some of the graphics. Supported image formats are gif, jpg and png.
jpgraph is an open source php tutorial to prepare a dedicated class library. It makes drawing a very simple thing, you just need to remove the relevant data from the database tutorials, define the title, the chart type and so on, you only need to learn to master one of the few jpgraph built-in functions (you can refer to jpgraph attached Example of learning), using a few lines of code can make a cool stunning chart!
2.jpgraph download installation and use
jpgraph's official download address is: http://jpgraph.net/download/
Note that when downloading, jpgraph is divided into several versions, you can determine according to your php version to download that version of the jpgraph library file.
Installation is relatively simple, but need to pay attention to the following two points:
Make sure your php version is at least 4.04 (but I guess it's generally over 5.0 now, should not be a problem).
Also have to support the gd library, jpgraph gd library is based, as gd library version is free.
Download completed jpgraph, extract the archive to any directory, into the jpgraph- version number directory, there are two directories, the other txt file is a simple user guide, you can have a look and understanding. docportal directory to help the system directory, including the installation of the configuration from the beginning to the instructions, functions introduced, and so on, if you have the patience, you can take a good look.
We mainly need the examples directory, which contains the jpgraph library file and a lot of sample files, we can see the sample file to learn it, so learning to use jpgraph is the fastest.
There is a file called jpg-config.inc in the jpgraph library file directory, which is the jpgraph configuration file, through which you can set jpgraph related parameters, such as setting jpgraph's cache folder and ttf (font) Folder and other content.
Precautions:
The cache folder path can be defined by itself, while the ttf (fonts) folder must be% system% / fonts.
Make sure PHP has write permission on the cache folder.
Note that the program encoding utf-8 encoding.
3 simple sample About jpgraph sample program in the examples directory is really enough, I will not be too wordy, simply explain the wording and a small example.
First in the program reference to include jpgraph library file:
require_once ('jpgraph / jpgraph.php');
require_once ('jpgraph / jpgraph_line.php');
Then start creating the graphic object:
$ graph = new graph (350,250);
Set various styles of graphics and charts Attributes:
$ graph-> setscale ("textlin");
$ graph-> img-> setmargin (30, 90, 40, 50);
$ graph-> xaxis-> setfont (ff_font1, fs_bold);
Lastly displayed:
$ graph-> add ($ lineplot);
$ graph-> stroke ();
Here's a simpler but complete example of a jpgraph program:
setscale ("textlin");
$ graph-> img-> setmargin (30, 90, 40, 50);
$ graph-> xaxis-> setfont (ff_font1, fs_bold);
$ graph-> title-> set ("dashed lineplot");
// create the linear plot
$ lineplot = new lineplot ($ ydata);
$ lineplot-> setlegend ("test 1");
$ lineplot-> setcolor ("blue");
// style can also be specified as setstyle ([1 | 2 | 3 | 4]) or
// setstyle ("solid" | "dotted" | "dashed" | "lobgdashed")
$ lineplot-> setstyle ("dashed");
// add the plot to the graph
$ graph-> add ($ lineplot);
// display the graph
$ graph-> stroke ();
?>
This jpgraph library to the basic introduction is over, and then I will release the article I wrote has been packaged jpgraph library class files, and there may be a summary of the jpgraph FAQ, I welcome everyone to put forward Opinion oh.