<?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(); //输出图像
?>