This article illustrates how PHP uses Jpgraph to draw a simple x-y coordinate diagram. Share to everyone for your reference. The implementation methods are as follows:
<?php
include ("src/jpgraph.php");
Include ("src/jpgraph_line.php");
The data that will be created for the chart is stored in an array
$data = Array (19,23,34,38,45,67,71,78,85,87,90,96);
$graph = new Graph (400,300); Create a new Graph object
$graph->setscale ("Textlin");//Set scale style
$graph->img->setmargin (30,30,80,30); Set the chart boundary
$graph->title->set ("year to Date Cost");//Set the chart title
//Create The linear plot
$lineplot =new Lineplot ($data); Create a new Lineplot object
$lineplot->setlegend ("Amount (M dollars)");//Set legend text
$lineplot->setcolor ("Red"); Set the color of the curve/
/ADD The plot to
the graph $graph->add ($lineplot);//Draw curves on the chart
//Display the graph
$ Graph->stroke (); Output Image
?>
The post-run effect chart is as follows:
I hope this article will help you with your PHP program design.