source: trunk/xgraph/jpgraph/Examples/vivid_example.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.8 KB
Line 
1<?php
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_bar.php');
4require_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// Create the graph. These two calls are always required
21$graph = new Graph(400,300);   
22
23$graph->SetScale("textlin");
24if ($theme) {
25  $graph->SetTheme(new $theme());
26}
27$theme_class = new VividTheme;
28$graph->SetTheme($theme_class);
29
30$plot = array();
31// Create the bar plots
32for ($i = 0; $i < 4; $i++) {
33  $plot[$i] = new BarPlot($data[$i]);
34  $plot[$i]->SetLegend('plot'.($i+1));
35}
36//$acc1 = new AccBarPlot(array($plot[0], $plot[1]));
37//$acc1->value->Show();
38$gbplot = new GroupBarPlot(array($plot[2], $plot[1] ));
39
40for ($i = 4; $i < 8; $i++) {
41  $plot[$i] = new LinePlot($data[$i]);
42  $plot[$i]->SetLegend('plot'.$i);
43  $plot[$i]->value->Show();
44}
45
46$graph->Add($gbplot);
47$graph->Add($plot[4]);
48
49$title = "VividTheme Example";
50$title = mb_convert_encoding($title,'UTF-8');
51$graph->title->Set($title);
52$graph->xaxis->title->Set("X-title");
53$graph->yaxis->title->Set("Y-title");
54
55// Display the graph
56$graph->Stroke();
57?>
Note: See TracBrowser for help on using the repository browser.