具体实现方法如下:
<?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(); //输出图像 ?>
运行后效果图如下:
相关推荐:
php图形操作之jpgraph
php报表之jpgraph柱状图实例代码
jpgraph类库简介 ntgraph graph下载 pyqtgrap
以上就是php使用jpgraph绘制坐标图基础篇的详细内容。