1. 程式人生 > >柱狀圖單系列

柱狀圖單系列

<?php
require_once ("src/jpgraph.php");
require_once ("src/jpgraph_bar.php");
 
$data  = array(19,23,34,38,45,67,71,78,85,87,96,145);         
$ydata = array("1","2","3","4","5","6","7","8","9","10","11","12");
 
$graph = new Graph(500,300);  //建立新的Graph物件
$graph->SetScale("textlin");  //刻度樣式
$graph
->SetShadow(); //設定陰影 $graph->img->SetMargin(40,30,40,50); //設定邊距 $graph->graph_theme = null; //設定主題為null,否則value->Show(); 無效 $barplot = new BarPlot($data); //建立BarPlot物件 $barplot->SetFillColor('blue'); //設定顏色 $barplot->value->Show(); //設定顯示數字 $graph->Add($barplot); //將柱形圖新增到影象中
$graph->title->Set("CDN流量圖"); $graph->xaxis->title->Set("月份"); //設定標題和X-Y軸標題 $graph->yaxis->title->Set("流 量(Mbits)"); $graph->title->SetColor("red"); $graph->title->SetMargin(10); $graph->xaxis
->title->SetMargin(5); $graph->xaxis->SetTickLabels($ydata); $graph->title->SetFont(FF_SIMSUN,FS_BOLD); //設定字型 $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->xaxis->SetFont(FF_SIMSUN,FS_BOLD); $graph->Stroke(); ?>