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

来源:互联网 发布:阿基诺三世知乎 编辑:程序博客网 时间:2024/05/22 07:01
  1. jpgraph的安装和配置  
  2. 1,官网下载  文件包  
  3. 2,解压  文件包  
  4. 3,拷贝到你的开发环境下----注意的是:把src目录的所有其他文件 全部剪切到Examples文件内,在剪切是先在Examples内建立jpgraph文件夹(名字一定得是jpgraph,因为其功能文件引用都是这个文件名为准)  
  5.       只留下docportal    和    Examples  这个2个文件即可  
  6. 4,执行你本地的环境---即可看见所有的jpgraph案例:http://localhost/Bbiao/jpgraph/Examples/  
  7.   
  8. jpgraph支持语言文件   --------   jpgraph_ttf.inc.php  
  9. // Chinese font  
  10. define("FF_SIMSUN",30);  
  11. define("FF_CHINESE",31);  
  12. define("FF_BIG5",32);  
  13.   
  14.   
  15. 比如:  
  16. <?php   
  17. require_once ('jpgraph/jpgraph.php');  
  18. require_once ('jpgraph/jpgraph_bar.php');  
  19.   
  20. $datay1=array(13,8,19,7,17,6);  
  21. $datay2=array(40,5,2,7,5,25);  
  22.   
  23. // Create the graph.  
  24. $graph = new Graph(350,250);  
  25. $graph->SetScale('textlin');  
  26. $graph->SetMarginColor('white');  
  27.   
  28. // Setup title  
  29. $graph->title->Set(iconv("UTF-8","GB2312//IGNORE","咋地三炮,我要支持中文!")) ;   //支持中文标题  
  30. $graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);  
  31. // Create the first bar  
  32. $bplot = new BarPlot($datay1);  
  33. $bplot->SetFillGradient('AntiqueWhite2','AntiqueWhite4:0.8',GRAD_VERT);  
  34. $bplot->SetColor('darkred');  
  35.   
  36. // Create the second bar  
  37. $bplot2 = new BarPlot($datay2);  
  38. $bplot2->SetFillGradient('olivedrab1','olivedrab4',GRAD_VERT);  
  39. $bplot2->SetColor('darkgreen');  
  40.   
  41. // And join them in an accumulated bar  
  42. $accbplot = new AccBarPlot(array($bplot,$bplot2));  
  43. $graph->Add($accbplot);  
  44.   
  45. $graph->Stroke();  
  46. ?>  
  47.   
  48. 既可实现php报表需求!