<?php
header("Content-type:text/html;charset=utf-8");
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$x = array("Watermelon","apple","pear","banana","Strawberry"); //設置x軸數據
$y = array("80","78","56","66","45"); //設置y軸數據
$grahp = new Graph(600,400); //設置畫布大小
$grahp -> SetScale('textlin'); //設置座標刻度類型
$barplot = new BarPlot($y); //實例化baeplot對象
$grahp -> xaxis -> SetTickLabels($x); //
$grahp -> title -> set(iconv("utf-8","gb2312","水果一月份銷售量")); //統計圖標題
$grahp->title->SetFont(FF_SIMSUN, FS_NORMAL,15); //標題字體
$grahp -> xaxis -> title -> SetFont(FF_SIMSUN,FS_BOLD);
$grahp -> xaxis -> title -> Set(iconv("utf-8", "gb2312", "水果名稱"));
$grahp -> yaxis -> title -> SetFont(FF_SIMSUN,FS_BOLD);
$grahp -> yaxis -> title -> Set(iconv("utf-8", "gb2312", "數量(公斤)"));
$grahp->Add($barplot); //
$barplot->value->show();
$grahp->Stroke(); //輸出圖像
?>