Heim  >  Artikel  >  Backend-Entwicklung  >  php中jpgraph类库的使用介绍_PHP教程

php中jpgraph类库的使用介绍_PHP教程

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

用Jpgraph,只要了解它的一些内置函数,可以轻松得画出折线图、柱形图、饼状图等图表。

首先要保证PHP打开了Gd2的扩展:

打开PHP.ini,定位到extension=php_gd2.dll,把前面的分号删掉。

然后下载Jpgraph,http://www.aditus.nu/jpgraph/,解压到一个文件夹中。如 E:\Software\web\www\jpgraph。

打开PHP.ini,修改include_path参数,增加Jpgraph的路径,如include_path=",;E:\Software\web\www\jpgraph",重启Apache服务。

这样环境就配好了。

下面附上一段例程。

复制代码 代码如下:

  require_once '../jpgraph/src/jpgraph.php';
  require_once '../jpgraph/src/jpgraph_line.php';
  require_once '../jpgraph/src/jpgraph_bar.php';
  // y 轴数据,以数组形式赋值
  $ydata = array(12,4,9,15,11,10,9,7,15,7);

  // 创建 Graph 类,350 为宽度,250 长度,auto:表示生成的缓存文件名是该文件的文件名+扩展名(.jpg .png .gif ……)
  $graph = new Graph(350,250,"auto");

  // 设置刻度类型,x轴刻度可作为文本标注的直线刻度,y轴为直线刻度
  $graph->SetScale("textlin");

  // 创建坐标类,将y轴数据注入
  $lineplot=new LinePlot($ydata);

  // y 轴连线设定为蓝色
  $lineplot->SetColor("blue");

  // 坐标类注入图标类
  $graph->Add($lineplot);

  // 显示图
  $graph->Stroke(); ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/328130.htmlTechArticle用Jpgraph,只要了解它的一些内置函数,可以轻松得画出折线图、柱形图、饼状图等图表。 首先要保证PHP打开了Gd2的扩展: 打开PHP.ini,定位...
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