不過功能更強大 可是比較醜比較單調
official
方法:
<img src="graphing.php"/>
當作圖片宣告
graphing.php:
//jpgraph的使用方法
//這頁會輸出一張圖片, 欲使用的話插入圖片, src是這頁的URL即可
require("config.php");
include_once ("./jpgraph/src/jpgraph.php");
include_once ("./jpgraph/src/jpgraph_bar.php");
$SQL = "SELECT UID, COUNT(UID) AS count FROM `performance` GROUP BY UID ORDER BY COUNT(UID) DESC";
$query = mysql_query($SQL);
while($result = mysql_fetch_array($query)){
$name[] .= $result['UID'];
$count[] .= $result['count'];
}
// Create the graph. These two calls are always required
$graph = new Graph(600,400,"auto");
$graph->SetScale("textint");
$graph->SetColor("lightyellow");
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(60,30,30,50);
// Create a bar pot
$bplot = new BarPlot($count);
// 長條的顏色
$bplot->SetFillColor('navy');
// 長條的寬度
$bplot->SetWidth(70);
$graph->Add($bplot);
// Setup the titles
$graph->title->Set("performance of pilotTV");
//設定字體 設成中文字
$graph->title->SetFont(FF_CHINESE, FS_NORMAL, 12);
$graph->yaxis->SetFont(FF_CHINESE);
$graph->xaxis->SetFont(FF_CHINESE);
$graph->xaxis->title->SetFont(FF_CHINESE, FS_NORMAL, 12);
$graph->yaxis->title->SetFont(FF_CHINESE, FS_NORMAL, 12);
$graph->xaxis->title->Set("姓名");
$graph->yaxis->title->Set("業績");
$graph->yaxis->title->SetAngle(0);
$graph->yaxis->title->Align('left');
$graph->xaxis->SetTickLabels($name);
// Display the graph
$graph->Stroke();
?>
就這樣 囧
參數有很多很多要設定 可是可以設定的滿完整的
抓下來的檔案有詳細的document和class說明
是可以仔細研究的工具之一
沒有留言:
張貼留言