jpGraph學習——繪製3D餅形圖

<?php 

//XY座標圖


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(600,500);


//設置圖像邊界範圍


$graph->img->SetMargin(30,30,80,30);


//設置標題


$graph->title->SetFont(FF_CHINESE); //--設置支持中文標題


$graph->title->Set("3D餅形圖");


//獲得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();

輸出:php

相關文章
相關標籤/搜索