茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1669412 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00024.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2010/2/10 3:00:50

[php] JPGraph



簡介 ::
作網頁需要使用到自動生成的圖片製作報表的時候,是否常常被 image function 一堆長長的指令搞暈頭,而在算幾個px的時候又再一次暈頭。來嚐試這個方便的繪圖物件吧!

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();
		?>
	



參考文件:
JpGraph :: php的繪圖物件 :: 幻想的世界
在世界的中心呼喊正太 - [php] 用php製作圖表 - JpGraph
minealan's tech: [php] JPGraph
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|