Jpgraph图表无缝集成TP,图表引擎驱动

浏览:11940 最后更新:2016-03-02 21:55 分类:引擎 关键字: 图表,报表
将Jpgraph无缝集成到 TP,可以生成饼状图,线状图,柱状图等等,
先将附件里面的Jpgraph.zip插件解压,复制到ThinkPHP/Vendor目录下面,然后将驱动文件"Chart.class.php"复制到'ThinkPHP/Lib/Think/Util',这个目录下面,然后就可以直接在action文件里面直接使用,
例:
class TestAction extends Action{

//3D饼图
function index(){
$chart = new Chart();
$title = "3D饼图"; //标题
$data = array(20,27,45,75,90,10,20,40); //数据
$size = 140; //尺寸
$width = 750; //宽度
$height = 350; //高度
$legend = array("aaaa ","bbbb","cccc","dddd ","eeee ","ffff ","gggg ","hhhh ");//说明
$chart->create3dpie($title,$data,$size,$height,$width,$legend);
}

//柱状图
function test1(){
$chart = new Chart();
$title = "柱状图"; //标题
$data = array(20,27,45,75,90,10,80,100); //数据
$size = 140; //尺寸
$width = 750; //宽度
$height = 350; //高度
$legend = array("aaaa ","bbbb","cccc","dddd ","eeee ","ffff ","gggg ","hhhh ");//说明
$chart->createcolumnar($title,$data,$size,$height,$width,$legend);
}
//线图
function test1(){
$chart = new Chart();
$title = "柱状图"; //标题
$data = array(20,27,45,75,90,10,80,100); //数据
$size = 140; //尺寸
$width = 750; //宽度
$height = 350; //高度
$legend = array("aaaa ","bbbb","cccc","dddd ","eeee ","ffff ","gggg ","hhhh ");//说明
$chart->createmonthline($title,$data,$size,$height,$width,$legend);
}

//环状图
function test1(){
$chart = new Chart();
$title = "柱状图"; //标题
$data = array(20,27,45,75,90,10,80,100); //数据
$size = 140; //尺寸
$width = 750; //宽度
$height = 350; //高度
$legend = array("aaaa ","bbbb","cccc","dddd ","eeee ","ffff ","gggg ","hhhh ");//说明
$chart->createring($title,$data,$size,$height,$width,$legend);
}

//横柱图
function test2(){
$chart = new Chart();
$title = "柱商务图"; //标题
$subtitle = "2012 年6月";
$data = array(20,27,45,75,90,100,80,100,300,500,1000,200,300,100,400,600); //数据
$size = 140; //尺寸
$width = 750; //宽度
$height = 350; //高度
$legend = array("张三1","张三2","张三3","张三4","张三5","张三6","张三7","张三8");//说明
$chart = new Chart();
$chart->createhorizoncolumnar($title,$subtitle,$data,$size,$height,$width,$legend);
}
}
发一个测试的饼图
评论( 相关
后面还有条评论,点击查看>>