Exemplo n.º 1
0
 public static function pieShow($piedata, $piename, $title)
 {
     //饼状图生成
     $graph = new PieGraph(LENHSIZE, HEISIZE);
     //设置画布尺寸
     $graph->img->SetMargin(LEFT, RIGHT, UP, DOWN);
     $graph->SetShadow();
     $graph->title->set($title);
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE);
     $num = count($piedata);
     //如果个数大于10则用2D显示,否则用3D显示
     if (num < 10) {
         $pieplot = new PiePlot3D($piedata);
     } else {
         $pieplot = new PiePlot($piedata);
     }
     $pieplot->setCenter(0.4);
     $pieplot->SetLegends($piename);
     $graph->legend->SetColumns(1);
     $pieplot->value->Show();
     $graph->legend->SetPos(0.01, 0.01, 'right', 'right');
     //设置图例显示属性
     $graph->legend->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE - 6);
     $graph->Add($pieplot);
     //借出次数最多物品突出显示
     $max = max($piedata);
     foreach ($piedata as $key => $value) {
         if ($value == $max) {
             $pieplot->ExplodeSlice($key);
         }
     }
     // $graph->AddText(new text("jhgjhs"),false);
     // $pieplot->ExplodeSlice( 0 );
     $num = rand(0, RAND);
     // echo var_dump($num);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     // echo var_dump($name);
     $graph->Stroke($name);
     return $name;
 }