复制代码 代码如下:
<?php
$datay=array(); //纵坐标数据
$datax=array(); //横坐标数据
foreach ($usernums as $key => $value){
$datay[] = $value;
$datax[] = $userids[$key];
}
require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php');
require_once (‘jpgraph-3.0.7/jpgraph/jpgraph_bar.php');
// create the graph. these two calls are always required
$graph = new graph(800,600); //图像高宽
$graph->setscale(“textlin”);
$graph->xaxis->setticklabels($datax);
$graph->xaxis->setfont(ff_verdana,fs_normal,10);
$graph->xaxis->setlabelangle(30);
$graph->yaxis->scale->setgrace(20);
$graph->xaxis->scale->setgrace(20);
// add a drop shadow
$graph->setshadow();
// adjust the margin a bit to make more room for titles
$graph->img->setmargin(40,30,20,40);
// create a bar pot
$bplot = new barplot($datay);
// adjust fill color
$bplot->setfillcolor(‘orange');
$bplot->value->show();
$bplot->value->setfont(ff_arial,fs_bold,10);
$bplot->value->setangle(45);
$bplot->value->setformat(‘%d');
$graph->add($bplot);
// setup the titles
$graph->title->set(iconv(“utf-8″, “gb2312″,”用户消费报表图”));
$graph->xaxis->title->set(iconv(“utf-8″, “gb2312″,”用户姓名”));
$graph->yaxis->title->set(iconv(“utf-8″, “gb2312″,”用户订单数量”));
$graph->xaxis->title->setfont(ff_simsun,fs_bold);
$graph->yaxis->title->setfont(ff_simsun,fs_bold);
$graph->title->setfont(ff_simsun,fs_bold);
// display the graph
$graph->stroke();
?>
效果图:
官方网站 http://jpgraph.net/download/ 硕编程下载地址 http://www.jb51.net/codes/38194.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!