PHP using Jpgraph to draw a simple x-y coordinate diagram _php tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.