複数の棒グラフを作成するには、GroupBarPlotオブジェクトを使用します。
BarPlotオブジェクトを複数作成し、GroupBarPlotオブジェクトでグループ化
しGraphオブジェクトへ追加します。
<?php require_once 'jpgraph.php'; require_once 'jpgraph_bar.php'; $xdata = array('Jan','Feb','Mar','Apr','May'); $graph = new Graph(200,150,'auto'); $graph->SetScale('textlin'); $graph->xaxis->SetTickLabels($xdata); $ydata1 = array(13,9,17,8,13); $plot1 = new BarPlot($ydata1); $plot1->SetFillColor('orange'); $ydata2 = array(17,8,13,13,9); $plot2 = new BarPlot($ydata2); $plot2->SetFillColor('lightblue'); $gplot = new GroupBarPlot(array($plot1,$plot2)); $graph->Add($gplot); $graph->Stroke(); ?>
グラフを見やすくするため、BarPlotのSetFillColorで棒の色を指定します。
Copyright 1997-2010 BBB All rights reserved.