Subversion Repositories Applications.annuaire

Rev

Rev 232 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 442
Line 13... Line 13...
13
 
13
 
Line 14... Line 14...
14
class Statistiques {
14
class Statistiques {
15
 
15
 
-
 
16
	const GRAPH_CAMEMBERT = 'pie';
-
 
17
	const GRAPH_COURBE = 'courbe';
-
 
18
	private $chemin_lib_graph = '';
-
 
19
	
-
 
20
	public function __construct() {
Line 16... Line 21...
16
	const GRAPH_CAMEMBERT = 'pie';
21
		$this->chemin_lib_graph = Config::get('chemin_jpgraph');
-
 
22
	}
Line 17... Line -...
17
	const GRAPH_COURBE = 'courbe';
-
 
18
 
-
 
19
	public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
23
 
20
 
-
 
21
		// Inclusion de la librairie JpGraph
24
	public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
22
		include_once("lib/jpgraph.php");
25
		include_once $this->chemin_lib_graph.'jpgraph.php';
23
		$graph = null;
26
		
24
 
27
		$graph = null;
25
		switch($type_graphique) {
-
 
26
			case Statistiques::GRAPH_CAMEMBERT:
28
		switch($type_graphique) {
27
				$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
29
			case Statistiques::GRAPH_CAMEMBERT:
28
			break;
30
				$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
29
 
-
 
30
			case Statistiques::GRAPH_COURBE:
31
				break;
31
				$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
32
			case Statistiques::GRAPH_COURBE:
32
			break;
-
 
33
 
33
				$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
Line 34... Line 34...
34
			default:
34
				break;
35
				$graph = $this->genererGraphiqueCourbe($valeurs);
35
			default:
Line 36... Line 36...
36
			break;
36
				$graph = $this->genererGraphiqueCourbe($valeurs);
37
		}
-
 
38
 
37
		}
39
		return $graph;
-
 
40
	}
-
 
41
 
38
 
42
	public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
-
 
43
 
39
		return $graph;
44
		include_once("lib/jpgraph_pie.php");
-
 
-
 
40
	}
45
		$graph = new PieGraph($taille[0],$taille[1]);
41
 
46
		
42
	public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
47
		$legendes = array_keys($valeurs);
-
 
48
	
-
 
49
		$valeurs = array_values($valeurs);
-
 
50
 
-
 
51
		$oPie = new PiePlot($valeurs);
43
		include_once $this->chemin_lib_graph.'jpgraph_pie.php';
52
		$oPie->SetLegends($legendes);
44
		$legendes = array_keys($valeurs);
53
 
-
 
54
		// Ajouter le titre du graphique
45
		$valeurs = array_values($valeurs);
55
		$graph->title->Set($titre);
-
 
56
 
46
		//die('<pre>'.print_r($valeurs, true).'</pre>');
57
		// position du graphique (légèrement à droite)
47
		$oPie = new PiePlot($valeurs);
Line -... Line 48...
-
 
48
		$oPie->SetLegends($legendes);
-
 
49
		// position du graphique (légèrement à droite)
-
 
50
		$oPie->SetCenter(0.35);
58
		$oPie->SetCenter(0.35);
51
		$oPie->SetValueType(PIE_VALUE_PER);
59
 
52
		// Format des valeurs de type "entier"
60
		$oPie->SetValueType(PIE_VALUE_PER);
53
		$oPie->value->SetFormat('%1.2f%%');
Line 61... Line 54...
61
 
54
 
62
		// Format des valeurs de type "entier"
-
 
63
		$oPie->value->SetFormat('%1.2f%%');
55
		$graph = new PieGraph($taille[0],$taille[1]);
Line 64... Line 56...
64
 
56
		// Ajouter le titre du graphique
65
		$graph->Add($oPie);
57
		$graph->title->Set($titre);
Line 66... Line 58...
66
		return $graph;
58
		$graph->Add($oPie);
Line 128... Line 120...
128
 
120
 
129
		return $graph;
121
		return $graph;
Line 130... Line 122...
130
	}
122
	}
-
 
123
 
Line 131... Line -...
131
 
-
 
132
	public function combinerGraphiques($graph1, $graph2, $taille) {
124
	public function combinerGraphiques($graph1, $graph2, $taille) {
133
 
125
		include_once $this->chemin_lib_graph.'jpgraph_mgraph.php';
134
		include_once('lib/jpgraph_mgraph.php');
126
 
Line 135... Line 127...
135
		$mgraph = new MGraph($taille[0],$taille[1],"auto");
127
		$mgraph = new MGraph($taille[0],$taille[1],"auto");
Line 148... Line 140...
148
	}
140
	}
Line 149... Line 141...
149
	
141
	
150
	public function dessinerGraph($graph) {
142
	public function dessinerGraph($graph) {
151
		return $graph->Stroke(_IMG_HANDLER);
143
		return $graph->Stroke(_IMG_HANDLER);
152
	}
-
 
153
 
144
	}
154
}
145
}