[42] | 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(47,80,40,116);
|
---|
| 6 | $data2y=array(61,30,82,105);
|
---|
| 7 | $data3y=array(115,50,70,93);
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | // Create the graph. These two calls are always required
|
---|
| 11 | $graph = new Graph(350,200,'auto');
|
---|
| 12 | $graph->SetScale("textlin");
|
---|
| 13 |
|
---|
| 14 | $theme_class=new UniversalTheme;
|
---|
| 15 | $graph->SetTheme($theme_class);
|
---|
| 16 |
|
---|
| 17 | $graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135));
|
---|
| 18 | $graph->SetBox(false);
|
---|
| 19 |
|
---|
| 20 | $graph->ygrid->SetFill(false);
|
---|
| 21 | $graph->xaxis->SetTickLabels(array('A','B','C','D'));
|
---|
| 22 | $graph->yaxis->HideLine(false);
|
---|
| 23 | $graph->yaxis->HideTicks(false,false);
|
---|
| 24 |
|
---|
| 25 | // Create the bar plots
|
---|
| 26 | $b1plot = new BarPlot($data1y);
|
---|
| 27 | $b2plot = new BarPlot($data2y);
|
---|
| 28 | $b3plot = new BarPlot($data3y);
|
---|
| 29 |
|
---|
| 30 | // Create the grouped bar plot
|
---|
| 31 | $gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot));
|
---|
| 32 | // ...and add it to the graPH
|
---|
| 33 | $graph->Add($gbplot);
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | $b1plot->SetColor("white");
|
---|
| 37 | $b1plot->SetFillColor("#cc1111");
|
---|
| 38 |
|
---|
| 39 | $b2plot->SetColor("white");
|
---|
| 40 | $b2plot->SetFillColor("#11cccc");
|
---|
| 41 |
|
---|
| 42 | $b3plot->SetColor("white");
|
---|
| 43 | $b3plot->SetFillColor("#1111cc");
|
---|
| 44 |
|
---|
| 45 | $graph->title->Set("Bar Plots");
|
---|
| 46 |
|
---|
| 47 | // Display the graph
|
---|
| 48 | $graph->Stroke();
|
---|
| 49 | ?>
|
---|