首頁  >  文章  >  後端開發  >  php報表之jpgraph長條圖實例代碼

php報表之jpgraph長條圖實例代碼

高洛峰
高洛峰原創
2016-12-01 09:27:071313瀏覽

新手初識jpgraph一定會遇到各種各樣的問題,比如亂碼什麼的,本案例是jpgraph3.0.7製作,也經過本人的多次實驗,解決亂碼問題 
複製代碼 代碼如下: 
$datay=array(); //縱座標資料 
$datax=array(); //橫座標資料 
foreach ($usernums as $key => $value){ 
$datay[] = $value; 
$datax[] = $userids[$key]; 

require_once ('jpgraph-3.0.7/jpgraph/jpgraph.php'); 
require_once ('jpgraph-3.0.7/jpgraph/jpgraph_bar.php');
// Create the graph. These two calls are always required 
$graph = new Graph(800,600); //圖像高寬 
$graph->SetScale(“textlin”); 
$graph->xaxis->SetTickLabels( $datax); 
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10); 
$graph->xaxis->SetLabelglegle(30); 
$graph->yaxis->scale->SetAngle(30); 
$graph->yaxis->scale->SetAngle(20);
$graph->xaxis->scale->SetGrace(20); 
// Add a drop shadow 
$graph->SetShadow(); 
// Adjust the margin a bit to make more room for titles 🎟 >img->SetMargin(40,30,20,40); 
// Create a bar pot 
$bplot = new BarPlot($datay); 
// Adjust fill color 
$bplot->SetFillor(''prange) ; 
$bplot->value->Show(); 
$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); 
$bplot->value->SetAngle(45); >SetFormat('%d'); 
$graph->Add($bplot); 
// Setup the titles 
$graph->title->Set(iconv(“UTF-8″, “gb2312″,”用戶消費報表圖」)); 
$graph->xaxis->title->Set(iconv(“UTF-8″, “gb2312″,”使用者姓名”)); 
$graph->yaxis->title-> Set(iconv(“UTF-8″, “gb2312″,”使用者訂單數量”)); 
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD); 
$graph->yaxis->title- >SetFont(FF_SIMSUN,FS_BOLD); 
$graph->title->SetFont(FF_SIMSUN,FS_BOLD); 
// Display the graph 
$graph->Stroke(); 
?> 
?> 

?
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn