<?php
//引入類庫
require_once "/data/webroot/resource/php/src/jpgraph.php";
require_once "/data/webroot/resource/php/src/jpgraph_line.php";
$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);//第一條數(shù)據(jù)
$data2y=array(0=>3,1=>12,2=>18,3=>30,4=>28,5=>33,6=>43,7=>39,8=>36,9=>29,10=>15,11=>10);//第二條數(shù)據(jù)
//得到Graph對象
$graph=new Graph(400,400);
//設(shè)置X和Y軸樣式及Y軸的最大值最小值
$graph->SetScale("textint",-30,50);
//設(shè)置右側(cè)Y軸樣式及其最大值最小值
$graph->SetY2Scale("int",-30,50);
//設(shè)置圖像樣式,加入陰影
$graph->SetShadow();
//設(shè)置圖像邊界范圍
$graph->img->setMargin(40,30,50,70);
//設(shè)置標(biāo)題
$graph->title->Set("this is a test X-Y-Y");
//得到曲線實(shí)例
$linePlot=new LinePlot($data);
//得到第二條曲線
$linePlot2y=new LinePlot($data2y);
//將曲線加入到圖像中
$graph->Add($linePlot);
$graph->Add($linePlot2y);
//設(shè)置三個坐標(biāo)軸名稱
$graph->xaxis->title->Set("Month");
$graph->yaxis->title->Set("beijing");
$graph->y2axis->title->Set("ShangHai");
//設(shè)置兩條曲線的顏色
//設(shè)置兩條曲線的圖例
$linePlot->SetLegend("Beijing");
$linePlot2y->SetLegend("Shanghai");
//設(shè)置圖例樣式
$graph->legend->setlayout(LEGEND_HOR);
$graph->legend->Pos(0.45,0.9,"center","bottom");
//將圖像輸出到瀏覽器
$graph->Stroke();