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

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00002.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

PHP特區 : [分享]JpGraph

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[分享]讓php jpgraph支持中文的例子
讓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支持中文的例子
前一個主題 | 下一個主題 | | | |

討論串




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