[42] | 1 | <?php
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_bar.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_line.php');
|
---|
| 5 |
|
---|
| 6 | $theme = isset($_GET['theme']) ? $_GET['theme'] : null;
|
---|
| 7 |
|
---|
| 8 | $data = array (
|
---|
| 9 | 0 => array (0 => 79, 1 => -25, 2 => -7, 3 => 85, 4 => -26, 5 => -32, ),
|
---|
| 10 | 1 => array (0 => 76, 1 => 51, 2 => 86, 3 => 12, 4 => -7, 5 => 94, ),
|
---|
| 11 | 2 => array (0 => 49, 1 => 38, 2 => 7, 3 => -40, 4 => 9, 5 => -7, ),
|
---|
| 12 | 3 => array ( 0 => 69, 1 => 96, 2 => 49, 3 => 7, 4 => 92, 5 => -38, ),
|
---|
| 13 | 4 => array ( 0 => 68, 1 => 16, 2 => 82, 3 => -49, 4 => 50, 5 => 7, ),
|
---|
| 14 | 5 => array ( 0 => -37, 1 => 28, 2 => 32, 3 => 6, 4 => 13, 5 => 57, ),
|
---|
| 15 | 6 => array ( 0 => 24, 1 => -11, 2 => 7, 3 => 10, 4 => 51, 5 => 51, ),
|
---|
| 16 | 7 => array ( 0 => 3, 1 => -1, 2 => -12, 3 => 61, 4 => 10, 5 => 47, ),
|
---|
| 17 | 8 => array ( 0 => -47, 1 => -21, 2 => 43, 3 => 53, 4 => 36, 5 => 34, ),
|
---|
| 18 | );
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | // Create the graph. These two calls are always required
|
---|
| 22 | $graph = new Graph(400,300);
|
---|
| 23 |
|
---|
| 24 | $graph->SetScale("textlin");
|
---|
| 25 | if ($theme) {
|
---|
| 26 | $graph->SetTheme(new $theme());
|
---|
| 27 | }
|
---|
| 28 | $theme_class = new UniversalTheme;
|
---|
| 29 | $graph->SetTheme($theme_class);
|
---|
| 30 |
|
---|
| 31 | $plot = array();
|
---|
| 32 | // Create the bar plots
|
---|
| 33 | for ($i = 0; $i < 4; $i++) {
|
---|
| 34 | $plot[$i] = new BarPlot($data[$i]);
|
---|
| 35 | $plot[$i]->SetLegend('plot'.($i+1));
|
---|
| 36 | }
|
---|
| 37 | //$acc1 = new AccBarPlot(array($plot[0], $plot[1]));
|
---|
| 38 | //$acc1->value->Show();
|
---|
| 39 | $gbplot = new GroupBarPlot(array($plot[2], $plot[1] ));
|
---|
| 40 |
|
---|
| 41 | for ($i = 4; $i < 8; $i++) {
|
---|
| 42 | $plot[$i] = new LinePlot($data[$i]);
|
---|
| 43 | $plot[$i]->SetLegend('plot'.$i);
|
---|
| 44 | $plot[$i]->value->Show();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | $graph->Add($gbplot);
|
---|
| 48 | $graph->Add($plot[4]);
|
---|
| 49 |
|
---|
| 50 | $title = "UniversalTheme Example";
|
---|
| 51 | $title = mb_convert_encoding($title,'UTF-8');
|
---|
| 52 | $graph->title->Set($title);
|
---|
| 53 | $graph->xaxis->title->Set("X-title");
|
---|
| 54 | $graph->yaxis->title->Set("Y-title");
|
---|
| 55 |
|
---|
| 56 | // Display the graph
|
---|
| 57 | $graph->Stroke();
|
---|
| 58 | ?>
|
---|