php报表之jpgraph柱状图实例

jpgraph是php中一个非常非常强大的第三方报表工具,据说能完成一切你想要的图形…

新手初识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();

?>

  


效果图:

jpgraph下载地址:http://down.qiannao.com/space/file/bingxingke/share/2010/6/29/jpgraph-002d3.0.7.tar.gz/.page

转自:http://www.52blogger.com/archives/539

转载于:https://www.cnblogs.com/c3055/archive/2011/08/18/2144144.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值