4, in the jpgraph installation root directory has a jpg-config.inc.php (jpgraph configuration file), set the correct TTF font 5, check the PHP configuration file php. whether the execution time and memory in ini are sufficient. generally, 32 M is recommended as a required course for graph processing in PHP development, such as using PHP for image scaling, adding watermarks to images, and drawing, the use of PHP graphics usually requires PHP developers to have a deep understanding of the concept of graphics. Jpgraph is a graph processing class library developed using PHP. you can draw any graph based on your needs. you only need to enter the corresponding data and select the image to be generated, its application is very convenient in data Statistics Development. as the beginning of the php jpgraph Chinese manual, I will first introduce jpgraph and the simplified jpgraph installation tutorial, I hope to help my friends who use jpgraph for Development. the translation is not good, but please forgive me.
Introduction to jpgraph
What is jpgraph?
Jpgraph is a class library developed using PHP. it can draw 2D images in PHP4 and PHP5 environments, which greatly simplifies the efficiency of using PHP scripts to create dynamic images. In large-scale WEB development, the jpgraph class library can also be used as a part of graph preprocessing. In addition, the jpgraph class library allows you to create images using the PHP command line (CLI version) method.
Jpgraph version
Jpgraph has three main branches: 1. x. y mainly targets php4 and older gd libraries; 3. x. y is used in the php5 environment, but gd2 is required; 3. x. y-p is the Professional edition. The major difference between the Professional edition and free edition is that it provides some additional modules, including some graphic types and three-month email support. Therefore, when using jpgraph, download different jpgraph versions based on the PHP version.
Jpgraph instance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Require_once ('jpgraph/jpgraph. php '); Require_once ('jpgraph/jpgraph_line.php '); // Input data $ Ydata = array ); // Create a graph $ Graph = new Graph (350,250 ); $ Graph-> SetScale ('textline '); // Create a line chart $ Lineplot = new LinePlot ($ ydata ); $ Lineplot-> SetColor ('Blue '); // Create a measurement point on the graph $ Graph-> Add ($ lineplot ); // Display the image $ Graph-> Stroke (); ?> |
The preceding jpgraph instance draws a line chart based on the provided data, which is the simplest jpgraph instance.
What can jpgraph do?
The jpgraph class library can be used in two ways.
1. online: images are dynamically generated when a user accesses a webpage. This means that it takes some time for the user to view the webpage, which is used to generate images. Jpgraph supports caching to reduce the number of image generation times.
2. offline: images are generated in batches based on the command line method. in this case, latency is not a problem. you can generate more complex images. Although the library itself does not limit the required memory and execution time, PHP will have this impact. If you need to process more than 2000X2000 pixels, it is best not to use PHP when the data points are greater than 0.5 million images, unless you are prepared to give PHP a memory of MB.
What is not suitable for using the jpgraph class library?
If you need complex 2D/3D visualization scenarios, the jpgraph class library is not suitable for use, large planning projects are not suitable, and 64-bit OS is not supported.
Due to the complexity of CPU processing images, the server load needs to be considered. if the load is high, the memory limit is easily reached. For example, the minimum memory for processing images in PHP is 32 MB (at least 64 MB is recommended ). If the system simultaneously promotes 50 users to access, it requires 1.6 GB. Therefore, the best way is to use the cache mechanism.
After a brief introduction to jpgraph, The following describes the simplified installation method of jpgraph. it is suitable for php users who have a certain foundation. in the future, we will introduce the detailed jpgraph installation and configuration tutorial.
Php jpgraph installation tutorial
1. download the jpgraph class library.
2. download the jpgraph class library and decompress it to the place where PHP stores the class library. Generally, the decompressed folder is named jpgraph-3.x. you can name it jpgraph, so that when you use jpgraph, you can
1 2 3
|
Require_once ('jpgraph/jpgraph. php '); ?> |
Statement call.
3. edit the php. ini configuration file to enable the GD extension. you can use the phpinfo function to check whether GD2 is supported. generally, PHP5 comes with the GD2 extension by default, which only needs to be enabled.
4. there is a jpg-config.inc.php under the jpgraph installation root directory (jpgraph configuration file), set the correct TTF font
5. check whether the execution time and memory in the PHP configuration file php. ini are sufficient. generally, 32 MB is recommended.
6. to better debug the graph program, the output cache must also be disabled in php. ini.
7. to avoid alarms, you need to set the default time zone.
TIPS: When you install this library on the product server, you should not install this library in the directory specified by document root. only the installation script can directly access the library file. I think this is for security considerations.
The installation of jpgraph is very convenient.
So far, the introduction and simplified installation tutorial of php jpgraph has been completed. I hope that my translated php jpgraph Chinese manual will be helpful to my friends who are using jpgraph. you can leave a message for me. you are welcome to give different comments. You can also read the jpgraph English development documentation.