可以把jpGraph改成用function呼叫嗎?

edited 十月 2013 in PHP新手區
請教一下各位大大
下面這段是改寫jpGraph而寫成的
在index()裡面
第一個echo可以成功的呼叫出pie3dex2.php的圖
不過第二個echo卻無法將copy過來改寫成showPic()的圖給叫出來
然後第三個echo單獨呼叫showPic(),出現的是一堆亂碼
可是卻可以用test.php?op=showPic成功的叫出showPic()的圖

因為小弟想把jpGraph改成用function呼叫
只需帶參數、陣列進去,即可將圖秀出來
請問有什麼地方是我沒注意到,或是觀念錯誤?
小弟新手還在摸索中,希望各位大大能夠幫忙,感謝

<?php
include ("../jpgraph.php");
include ("../jpgraph_pie.php");
include ("../jpgraph_pie3d.php");

function index() {
echo "<img src='pie3dex2.php'><br>";
echo "<img src='showPic()'>";
showPic();
}

function showPic() {
// Some data
$data = array(20,27,45,75,90);

// Create the Pie Graph.
$graph = new PieGraph(350,200,"auto");
$graph->SetShadow();

// Set A title for the plot
$graph->title->Set("Example 1 3D Pie plot");
$graph->title->SetFont(FF_VERDANA,FS_BOLD,18);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1,0.2);

// Create pie plot
$p1 = new PiePlot3d($data);
$p1->SetTheme("sand");
$p1->SetCenter(0.4);
$p1->SetAngle(30);
$p1->value->SetFont(FF_ARIAL,FS_NORMAL,12);
$p1->SetLegends(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct"));

$graph->Add($p1);
$graph->Stroke();
}

switch($op) {
case "showPic":
showPic();
break;
default:
index();
break;
}

?>

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=2121

評論

Sign In or Register to comment.