1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
4 | |
---|
5 | $data1y=array(12,8,19,3,10,5); |
---|
6 | $data2y=array(8,2,11,7,14,4); |
---|
7 | |
---|
8 | // Create the graph. These two calls are always required |
---|
9 | $graph = new Graph(310,200); |
---|
10 | $graph->SetScale("textlin"); |
---|
11 | |
---|
12 | $graph->SetShadow(); |
---|
13 | $graph->img->SetMargin(40,30,20,40); |
---|
14 | |
---|
15 | // Create the bar plots |
---|
16 | $b1plot = new BarPlot($data1y); |
---|
17 | $b1plot->SetFillColor("orange"); |
---|
18 | $b2plot = new BarPlot($data2y); |
---|
19 | $b2plot->SetFillColor("blue"); |
---|
20 | |
---|
21 | // Create the grouped bar plot |
---|
22 | $gbplot = new GroupBarPlot(array($b1plot,$b2plot)); |
---|
23 | |
---|
24 | // ...and add it to the graPH |
---|
25 | $graph->Add($gbplot); |
---|
26 | |
---|
27 | $graph->title->Set("Example 21"); |
---|
28 | $graph->xaxis->title->Set("X-title"); |
---|
29 | $graph->yaxis->title->Set("Y-title"); |
---|
30 | |
---|
31 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
32 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
33 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
34 | |
---|
35 | // Display the graph |
---|
36 | $graph->Stroke(); |
---|
37 | ?> |
---|