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

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00087.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

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

發表者: 冷日 發表時間: 2010/2/10 3:05:53
讓php jpgraph支持中文的例子

以前用PHP作圖時必須要掌握複雜抽像的畫圖函數,或者借助一些網上下載的花柱形圖、餅形圖的類來實現。沒有一個統一的chart類來實現圖表的快速開發。

JpGraph就是解決這個問題的一個不錯的類庫。

jpgraph的官網:http://www.aditus.nu/jpgraph/

最新版本:支持PHP4的v1.2、支持PHP5的v3。

讓php jpgraph支持中文的例子

PHP:
<?php
include (./graph/jpgraph.php);
include (./graph/jpgraph_bar.php);
// Some data
$databary=array(152,7,16,5,7,14,9,3);
$databarx= array(中文,德文, hi, d,dddd,a,b,e) ;
// New graph with a drop shadow
$graph = new Graph(300,200,auto);
//$graph->SetShadow();
// Use a text X-scale
$graph->SetScale(textlin);
/**
* X坐標的內容
*/
$graph->xaxis->SetTickLabels($databarx);
//$graph->xaxis->SetTextLabelInterval(3);
$graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL);
// Set title and subtitle
$graph->title->Set(測試數據);
// Use built in font
/**
* 使用中文字體支持中文的顯示
*/
$graph->title->SetFont(FF_SIMSUN,FS_BOLD,14);
// create the bar plot
$b1 = new BarPlot($databary);
/**
* 這個是 圖例
*/
$b1->SetLegend(Temperature);
/**
* 這個是 柱狀的寬度
*/
$b1->SetAbsWidth(6);
/**
* 這個是 柱狀的投影, 不要
*/
//$b1->SetShadow();
// The order the plots are added determines whos ontop
$graph->Add($b1);
// Finally output the image
$graph->Stroke();
?>


注意,如果使用的是linux服務器,如果沒有安裝truetype字體,則需要上傳相關的字體到linux的/usr/X11R6/lib/X11/fonts/truetype目錄,上面的例子就需要傳
/usr/X11R6/lib/X11/fonts/truetype/simhei.ttf
/usr/X11R6/lib/X11/fonts/truetype/simsun.ttc


原文出處:讓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|