Home  >  Article  >  Backend Development  >  Introduction to the use of jpgraph class library in php_PHP tutorial

Introduction to the use of jpgraph class library in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:41933browse

With Jpgraph, as long as you understand some of its built-in functions, you can easily draw line charts, column charts, pie charts and other charts.

First make sure that PHP has the Gd2 extension turned on:

Open PHP.ini, locate extension=php_gd2.dll, and delete the semicolon in front of it.

Then download Jpgraph, http://www.aditus.nu/jpgraph/, and extract it to a folder. Such as E:Softwarewebwwwjpgraph.

Open PHP.ini, modify the include_path parameter, add the path of Jpgraph, such as include_path=",;E:Softwarewebwwwjpgraph", and restart the Apache service.

This way the environment is ready.

A routine is attached below.

Copy code The code is as follows:

 require_once '../jpgraph/src /jpgraph.php';
require_once '../jpgraph/src/jpgraph_line.php';
require_once '../jpgraph/src/jpgraph_bar.php';
// y-axis data, to Assignment in array form
 $ydata = array(12,4,9,15,11,10,9,7,15,7);

// Create a Graph class, 350 is the width, 250 is the length, auto: means that the generated cache file name is the file name + extension of the file (.jpg .png .gif...)
$graph = new Graph(350,250,"auto");

//Set the scale type. The x-axis scale can be used as a straight-line scale for text labeling, and the y-axis is a straight-line scale.
 $graph->SetScale("textlin");

// Create a coordinate class and inject y-axis data into
$lineplot=new LinePlot($ydata);

// Set the y-axis connection line to blue
$lineplot->SetColor("blue");

// Inject the coordinate class into the icon class
$graph->Add($lineplot);

// Display graph
$graph->Stroke(); ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328130.htmlTechArticleUsing Jpgraph, as long as you understand some of its built-in functions, you can easily draw line charts, column charts, and pie charts. Diagrams and other charts. First, make sure that PHP has the Gd2 extension turned on: Open PHP.ini and locate...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn