Heim  >  Artikel  >  Backend-Entwicklung  >  php使用Jpgraph绘制简单X-Y坐标图的方法_php技巧

php使用Jpgraph绘制简单X-Y坐标图的方法_php技巧

WBOY
WBOYOriginal
2016-05-16 20:14:011036Durchsuche

本文实例讲述了php使用Jpgraph绘制简单X-Y坐标图的方法。分享给大家供大家参考。具体实现方法如下:

<&#63;php 
include ("src/jpgraph.php"); 
include ("src/jpgraph_line.php"); 
//将要用于图表创建的数据存放在数组中 
$data = array(19,23,34,38,45,67,71,78,85,87,90,96); 
$graph = new Graph(400,300); //创建新的Graph对象 
$graph->SetScale("textlin"); //设置刻度样式 
$graph->img->SetMargin(30,30,80,30); //设置图表边界 
$graph->title->Set("Year to Date Cost"); //设置图表标题 
// Create the linear plot 
$lineplot=new LinePlot($data); // 创建新的LinePlot对象 
$lineplot->SetLegend("Amount(M dollars)"); //设置图例文字 
$lineplot->SetColor("red"); // 设置曲线的颜色 
// Add the plot to the graph 
$graph->Add($lineplot); //在统计图上绘制曲线 
// Display the graph 
$graph->Stroke(); //输出图像 
&#63;>

运行后效果图如下:

希望本文所述对大家的php程序设计有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn