<?php
// content="text/plain; charset=utf-8"
require_once('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay=array(80,78,50,66,45);
$datay2=array(40,60,70,50,30);
$x = array("Watermelon","apple","pear","banana","Strawberry"); //设置x轴数据
//创建画布
$graph = new Graph(600,400);
$graph->SetScale("textlin");;
//$graph->yaxis->scale->SetGrace(10);
$graph -> xaxis -> SetTickLabels($x);
//统计图标题
$graph->title->set(iconv("gb2312","gb2312", "水果一月、二月份销售量"));
$graph->title->SetFont(FF_SIMSUN, FS_NORMAL,15); //标题字体
$graph -> xaxis -> title -> SetFont(FF_SIMSUN,FS_BOLD);
$graph -> xaxis -> title -> Set(iconv("gb2312", "gb2312", "水果名称"));
$graph -> yaxis -> title -> SetFont(FF_SIMSUN,FS_BOLD);
$graph -> yaxis -> title -> Set(iconv("gb2312", "gb2312", "数量(公斤)"));
//设置背景格子
$graph->ygrid->Show(true,true);
$graph->ygrid->SetColor('gray','lightgray@0.5');
$graph->SetMarginColor('white');
// Create the "dummy" 0 bplot
$bplotzero = new BarPlot($datay2);
$ybplot1 = new BarPlot($datay);
$ybplot = new GroupBarPlot(array($ybplot1,$bplotzero));
//生成图例
$graph->Add($ybplot);
//显示纵坐标的值
$ybplot1->value->Show();
$bplotzero->value->show();
// .. and finally stroke the image back to browser
$graph->Stroke();
?>