예제 #1
0
 public function actionPie($id = -1)
 {
     include 'jpgraph/jpgraph.php';
     include 'jpgraph/jpgraph_pie.php';
     include 'jpgraph/jpgraph_pie3d.php';
     $data = $this->analyse($id);
     $ydata = array();
     $xdata = array();
     foreach ($data as $key => $value) {
         array_push($xdata, $key);
         array_push($ydata, $value);
     }
     if (count($data) == 0) {
         echo '近一个习惯起没有相应的反馈级记录';
         die;
     }
     $data = $ydata;
     $graph = new pieGraph(500, 500);
     $graph->img->SetMargin(100, 100, 100, 100);
     $pie3dplot = new piePlot3d($data);
     //定义饼图
     $pie3dplot->SetLegends($xdata);
     $pie3dplot->value->Show();
     $graph->Add($pie3dplot);
     $graph->Stroke();
 }
예제 #2
0
<?php

require_once "../src/jpgraph.php";
require_once "../src/jpgraph_pie.php";
require_once "../src/jpgraph_pie3d.php";
$data = array(0 => 3.5, 1 => 4.6, 2 => 9.1, 3 => 21.9, 4 => 42.3, 5 => 90.7, 6 => 183.5, 7 => 127.5, 8 => 61.4, 9 => 33.5, 10 => 11.5, 11 => 4.4);
//创建画布
$graph = new pieGraph(500, 500);
//设置图像边界范围
$graph->img->SetMargin(30, 30, 80, 30);
//设置标题
$graph->title->SetFont(FF_CHINESE);
$graph->title->Set("3D饼图--piePlot3d Test");
//得到3D饼图对象
$piePlot3d = new piePlot3d($data);
//设置图例
$piePlot3d->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"));
//设置图例位置
$graph->legend->Pos(0.1, 0.15, "left", "center");
//将绘制好的3D饼图加入到画布中
$graph->Add($piePlot3d);
//输出
$graph->Stroke();
예제 #3
0
 public function actionPie($id)
 {
     include 'jpgraph/jpgraph.php';
     include 'jpgraph/jpgraph_pie.php';
     include 'jpgraph/jpgraph_pie3d.php';
     $cate_name = Category::model()->findByPk($id)->cname;
     $data = $this->analyse($id);
     $ydata = array();
     $xdata = array();
     foreach ($data as $key => $value) {
         array_push($xdata, $key);
         array_push($ydata, $value);
     }
     if (count($data) == 0) {
         echo '近一个习惯起没有相应的反馈级记录';
         die;
     }
     $data = $ydata;
     $graph = new pieGraph(500, 500);
     $graph->img->SetMargin(100, 100, 100, 100);
     $graph->title->Set('近一个星期关于' . $cate_name . '的反馈情况');
     $pie3dplot = new piePlot3d($data);
     //定义饼图
     $pie3dplot->SetLegends($xdata);
     $graph->Add($pie3dplot);
     $graph->Stroke();
 }