-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_global.php
112 lines (77 loc) · 2.11 KB
/
graph_global.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
include_once 'inclusions.php';
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_bar.php');
$type = "participants";
if ( array_key_exists("type", $_GET) ) {
$type = $_GET["type"];
}
$stats = new GeneralStatistics();
$stats->load_graph_data($type);
// Create the graph. These two calls are always required
$width = 450;
$height = 300;
/*
$margin = 0;
if ( $type == "participants" ) $margin = 120;
$width += $margin;
*/
$timeout = 180; // Tempo (in minuti) di utilizzo del grafico in cache. 0 = infinito.
$graph = new Graph($width, $height, 'auto', $timeout);
$graph->SetScale("textlin");
$theme_class = new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$xlabels = array();
foreach ( $stats->graph_data as $tid => $team ) {
foreach ( $team->graph_data as $year => $val ) {
$xlabels[] = $year;
}
break;
}
$graph->xaxis->SetTickLabels( $xlabels );
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
// Create the bar plots
$plots = array();
foreach ( $stats->graph_data as $team ) {
$temp = array();
foreach ( $team->graph_data as $val ) $temp[] = $val;
$plot = new BarPlot( $temp );
$plots[] = $plot;
}
// Create the grouped bar plot
$gbplot = new GroupBarPlot( $plots );
$gbplot->SetWidth(0.37);
// ...and add it to the graPH
$graph->Add($gbplot);
$colors = array( "#cc1111", "blue", "#1111cc" );
$cont = 0;
foreach ( $plots as $plot ) {
$plot->SetColor("white");
$plot->SetFillColor( $colors[ $cont++ ] );
}
$title = "";
if ( $type == "participants" ) $title = "Numero di partecipanti ";
else $title = "Gol";
$graph->title->Set( $title );
/*
if ( $type == "participants" ) {
// Aggiungo la legenda
$cont = 0;
foreach ( $stats->graph_data as $team ) {
$plots[ $cont++ ]->SetLegend( $team->name );
}
//$graph->legend->SetReverse();
// Adjust the legend position
$graph->legend->SetPos(0.01, 0.5,'right','center');
$graph->legend->SetColumns(1);
$graph->legend->SetShadow();
}
// Adjust the margin
$graph->SetMargin(50,$margin,40,40);
*/
// Display the graph
$graph->Stroke();
?>