<?php
//引入類庫
require_once "../src/jpgraph.php";
require_once "../src/jpgraph_bar.php";
//柱形圖模擬數(shù)據(jù)
$data=array(0=>-21,1=>-3,2=>12,3=>19,4=>23,5=>29,6=>30,7=>22,8=>26,9=>18,10=>5,11=>-10);
//創(chuàng)建背景圖
$graph=new Graph(400,300);
//設置刻度樣式
$graph->SetScale("textlin");
//設置邊界范圍
$graph->img->SetMargin(30,30,80,30);
//設置標題
$graph->title->Set("BarPlot test");
//得到柱形圖對象
$barPlot=new BarPlot($data);
//設置柱形圖圖例
$barPlot->SetLegend("beijing");
//顯示柱形圖代表數(shù)據(jù)的值
$barPlot->value->show();
//將柱形圖加入到背景圖
$graph->Add($barPlot);
//設置柱形圖填充顏色
$barPlot->setfillcolor("yellow");
//設置邊框顏色
$barPlot->setcolor("red");
//將柱形圖輸出到瀏覽器
$graph->Stroke();
?>

Paste_Image.png