首頁 >後端開發 >php教程 > 请问jpgraph画饼图的有关问题

请问jpgraph画饼图的有关问题

WBOY
WBOY原創
2016-06-13 13:36:481063瀏覽

请教jpgraph画饼图的问题
画饼图的代码如下:

//画饼状图
function DrawPieGraph($width,$hight,$mainTitle,$labels_x,$datay)
{
// Create the Pie Graph. 
$graph = new PieGraph($width,$hight);

$theme_class= new UniversalTheme;
$graph->SetTheme($theme_class);

// Set A title for the plot
$graph->title->Set($mainTitle);
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,20);
// Create
$p1 = new PiePlot3D($datay);

$graph->legend->SetFont(FF_SIMSUN,FS_BOLD);
$p1->SetLegends($labels_x);
$graph->legend->Pos(0.5,0.99,'center','bottom');
$graph->legend->SetFrameWeight(0); //图例文字外框边框border设置为0
$graph->legend->SetFillColor('#FFFFFF'); //图例文字框内的填充颜色
$graph->legend->SetShadow('#C8C8C8', 0);
$graph->Add($p1);

$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#EE00EE','#2E8B57','#ADFF2F','#E5E5E5','#FF0000','#BF3EFF','#8B2500','#4876FF','#EEEE00','#00FF7F','#8B3E2F','#7A67EE'));
$p1->ExplodeSlice(1);
$graph->Stroke();
}

$mainTitle="2011年业务量统计表";
$labels_x=array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
$datay=array(62,180,85,58,22,115,85,100,34,105,85,55);

DrawPieGraph(800,650,$mainTitle,$labels_x,$datay);

这个代码可以执行。可是显示出来的饼图的每一块上面没有显示是几月份的数据,看着比较累,有没有办法把月份写在饼图上相对应的每一个色块上面?请大虾指点。在线等。。。

------解决方案--------------------
$lbl = array("一月\n%.1f%%","二月\n%.1f%%","三月\n%.1f%%",
"四月\n%.1f%%","五月\n%.1f%%","六月\n%.1f%%","七月\n%.1f%%","八月\n%.1f%%","九月\n%.1f%%","十月\n%.1f%%","十一月\n%.1f%%","十二月\n%.1f%%");
$p1->SetLabels($lbl);

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn