Home >Backend Development >PHP Tutorial >php实现报表(jpgraph插件实现)

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

WBOY
WBOYOriginal
2016-06-23 13:56:491398browse

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



比如:

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报表需求!




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn