分享好友 编程语言首页 频道列表

php报表之jpgraph柱状图实例代码

PHP教程  2015-11-13 14:190
新手初识jpgraph肯定会遇到各种各样的问题,比如乱码什么的,本案例是jpgraph3.0.7制作,也经过本人的多次实验,解决乱码问题
复制代码 代码如下:

<?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();
?>

效果图:
php报表之jpgraph柱状图实例代码
官方网站 http://jpgraph.net/download/  乐学网(lexue001.com)下载地址 http://www.lexue001.com/codes/38194.html

查看更多关于【PHP教程】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
JpGraph php柱状图使用介绍
以前用PHP作图时必须要掌握复杂抽象的画图函数,或者借助一些网上下载的花柱形图、饼形图的类来实现。没有一个统一的chart类来实现图表的快速开发。

0评论2015-11-1391

php中jpgraph类库的使用介绍
以下是对php中jpgraph类库的使用进行了详细的分析介绍,需要的朋友可以过来参考下

0评论2015-11-0785

更多推荐