php实现报表(jpgraph插件实现)

本文详细介绍了jpGraph图表库的安装步骤与配置方法,并通过一个示例展示了如何使用jpGraph生成带中文标题的柱状图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jpgraph的安装和配置
1,官网下载  文件包
2,解压  文件包
3,拷贝到你的开发环境下----注意的是:把src目录的所有其他文件 全部剪切到Examples文件内,在剪切是先在Examples内建立jpgraph文件夹(名字一定得是jpgraph,因为其功能文件引用都是这个文件名为准)
      只留下docportal    和    Examples  这个2个文件即可
4,执行你本地的环境---即可看见所有的jpgraph案例:http://localhost/Bbiao/jpgraph/Examples/

jpgraph支持语言文件   --------   jpgraph_ttf.inc.php
// Chinese font
define("FF_SIMSUN",30);
define("FF_CHINESE",31);
define("FF_BIG5",32);


比如:
<?php 
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');

$datay1=array(13,8,19,7,17,6);
$datay2=array(40,5,2,7,5,25);

// Create the graph.
$graph = new Graph(350,250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');

// Setup title
$graph->title->Set(iconv("UTF-8","GB2312//IGNORE","咋地三炮,我要支持中文!")) ;   //支持中文标题
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);
$bplot->SetColor('darkred');

// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);
$bplot2->SetColor('darkgreen');

// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot,$bplot2));
$graph->Add($accbplot);

$graph->Stroke();
?>

既可实现php报表需求!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值