Subversion Repositories Applications.annuaire

Rev

Rev 232 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 442
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   annuaire
6
* @package   annuaire
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/annuaire/
11
* @link      /doc/annuaire/
12
*/
12
*/
13
 
13
 
14
class Statistiques {
14
class Statistiques {
15
 
15
 
16
	const GRAPH_CAMEMBERT = 'pie';
16
	const GRAPH_CAMEMBERT = 'pie';
17
	const GRAPH_COURBE = 'courbe';
17
	const GRAPH_COURBE = 'courbe';
-
 
18
	private $chemin_lib_graph = '';
-
 
19
	
-
 
20
	public function __construct() {
-
 
21
		$this->chemin_lib_graph = Config::get('chemin_jpgraph');
-
 
22
	}
18
 
23
 
-
 
24
	public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
19
	public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
25
		include_once $this->chemin_lib_graph.'jpgraph.php';
20
 
-
 
21
		// Inclusion de la librairie JpGraph
-
 
22
		include_once("lib/jpgraph.php");
26
		
23
		$graph = null;
-
 
24
 
27
		$graph = null;
25
		switch($type_graphique) {
28
		switch($type_graphique) {
26
			case Statistiques::GRAPH_CAMEMBERT:
29
			case Statistiques::GRAPH_CAMEMBERT:
27
				$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
30
				$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
28
			break;
31
				break;
29
 
-
 
30
			case Statistiques::GRAPH_COURBE:
32
			case Statistiques::GRAPH_COURBE:
31
				$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
33
				$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
32
			break;
34
				break;
33
 
-
 
34
			default:
35
			default:
35
				$graph = $this->genererGraphiqueCourbe($valeurs);
36
				$graph = $this->genererGraphiqueCourbe($valeurs);
36
			break;
-
 
37
		}
37
		}
38
 
38
 
39
		return $graph;
39
		return $graph;
40
	}
40
	}
41
 
41
 
42
	public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
42
	public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
43
 
-
 
44
		include_once("lib/jpgraph_pie.php");
43
		include_once $this->chemin_lib_graph.'jpgraph_pie.php';
45
		$graph = new PieGraph($taille[0],$taille[1]);
-
 
46
		
-
 
47
		$legendes = array_keys($valeurs);
44
		$legendes = array_keys($valeurs);
48
	
-
 
49
		$valeurs = array_values($valeurs);
45
		$valeurs = array_values($valeurs);
50
 
-
 
-
 
46
		//die('<pre>'.print_r($valeurs, true).'</pre>');
51
		$oPie = new PiePlot($valeurs);
47
		$oPie = new PiePlot($valeurs);
52
		$oPie->SetLegends($legendes);
48
		$oPie->SetLegends($legendes);
53
 
-
 
54
		// Ajouter le titre du graphique
-
 
55
		$graph->title->Set($titre);
-
 
56
 
-
 
57
		// position du graphique (légèrement à droite)
49
		// position du graphique (légèrement à droite)
58
		$oPie->SetCenter(0.35);
50
		$oPie->SetCenter(0.35);
59
 
-
 
60
		$oPie->SetValueType(PIE_VALUE_PER);
51
		$oPie->SetValueType(PIE_VALUE_PER);
61
 
-
 
62
		// Format des valeurs de type "entier"
52
		// Format des valeurs de type "entier"
63
		$oPie->value->SetFormat('%1.2f%%');
53
		$oPie->value->SetFormat('%1.2f%%');
-
 
54
 
-
 
55
		$graph = new PieGraph($taille[0],$taille[1]);
-
 
56
		// Ajouter le titre du graphique
64
 
57
		$graph->title->Set($titre);
65
		$graph->Add($oPie);
58
		$graph->Add($oPie);
66
		return $graph;
59
		return $graph;
67
	}
60
	}
68
 
61
 
69
	public function genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y) {
62
	public function genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y) {
70
 
-
 
71
		include_once("lib/jpgraph_line.php");
63
		include_once $this->chemin_lib_graph.'jpgraph_line.php';
72
 
64
		
73
		// Création du conteneur
65
		// Création du conteneur
74
		$graph = new Graph($taille[0],$taille[1],"auto");
66
		$graph = new Graph($taille[0],$taille[1],"auto");
75
 
67
 
76
		$graph->img->SetMargin(50,30,50,100);   
68
		$graph->img->SetMargin(50,30,50,100);   
77
 
69
 
78
		// Lissage sur fond blanc (évite la pixellisation)
70
		// Lissage sur fond blanc (évite la pixellisation)
79
		$graph->img->SetAntiAliasing("white");
71
		$graph->img->SetAntiAliasing("white");
80
		$graph->SetMarginColor("white");  
72
		$graph->SetMarginColor("white");  
81
 
73
 
82
		// A détailler
74
		// A détailler
83
		$graph->SetScale("textlin");
75
		$graph->SetScale("textlin");
84
 
76
 
85
		// Ajouter une ombre
77
		// Ajouter une ombre
86
		$graph->SetShadow();
78
		$graph->SetShadow();
87
 
79
 
88
		// Ajouter le titre du graphique
80
		// Ajouter le titre du graphique
89
		$graph->title->Set($titre);
81
		$graph->title->Set($titre);
90
 
82
 
91
		// Afficher la grille de l'axe des ordonnées
83
		// Afficher la grille de l'axe des ordonnées
92
		$graph->ygrid->Show();
84
		$graph->ygrid->Show();
93
		// Fixer la couleur de l'axe (bleu avec transparence : @0.7)
85
		// Fixer la couleur de l'axe (bleu avec transparence : @0.7)
94
		$graph->ygrid->SetColor('#E6E6E6@0.7');
86
		$graph->ygrid->SetColor('#E6E6E6@0.7');
95
		// Des tirets pour les lignes
87
		// Des tirets pour les lignes
96
		$graph->ygrid->SetLineStyle('solid');
88
		$graph->ygrid->SetLineStyle('solid');
97
 
89
 
98
		// Afficher la grille de l'axe des abscisses
90
		// Afficher la grille de l'axe des abscisses
99
		//$graph->xgrid->Show();
91
		//$graph->xgrid->Show();
100
		// Fixer la couleur de l'axe (rouge avec transparence : @0.7)
92
		// Fixer la couleur de l'axe (rouge avec transparence : @0.7)
101
		//$graph->xgrid->SetColor('red@0.7');
93
		//$graph->xgrid->SetColor('red@0.7');
102
		// Des tirets pour les lignes
94
		// Des tirets pour les lignes
103
		//$graph->xgrid->SetLineStyle('solid');
95
		//$graph->xgrid->SetLineStyle('solid');
104
		$graph->xaxis->SetLabelAngle(90);
96
		$graph->xaxis->SetLabelAngle(90);
105
		$graph->xaxis->SetTextLabelInterval(4);
97
		$graph->xaxis->SetTextLabelInterval(4);
106
 
98
 
107
		// Créer une courbes
99
		// Créer une courbes
108
		$courbe = new LinePlot(array_values($valeurs));
100
		$courbe = new LinePlot(array_values($valeurs));
109
 
101
 
110
		// Chaque point de la courbe ****
102
		// Chaque point de la courbe ****
111
		// Type de point
103
		// Type de point
112
		$courbe->mark->SetType(MARK_FILLEDCIRCLE);
104
		$courbe->mark->SetType(MARK_FILLEDCIRCLE);
113
		// Couleur de remplissage
105
		// Couleur de remplissage
114
		$courbe->mark->SetFillColor("red");
106
		$courbe->mark->SetFillColor("red");
115
		// Taille
107
		// Taille
116
		$courbe->mark->SetWidth(1);
108
		$courbe->mark->SetWidth(1);
117
 
109
 
118
		// Paramétrage des axes
110
		// Paramétrage des axes
119
		//$graph->xaxis->title->Set($nom_axe_x);
111
		//$graph->xaxis->title->Set($nom_axe_x);
120
		$txt = new Text($nom_axe_x,270,460); 
112
		$txt = new Text($nom_axe_x,270,460); 
121
		$graph->xaxis->SetTickLabels(array_keys($valeurs));
113
		$graph->xaxis->SetTickLabels(array_keys($valeurs));
122
 
114
 
123
		// Paramétrage des axes
115
		// Paramétrage des axes
124
		$graph->yaxis->title->Set($nom_axe_y);
116
		$graph->yaxis->title->Set($nom_axe_y);
125
 
117
 
126
		// Ajouter la courbe au conteneur
118
		// Ajouter la courbe au conteneur
127
		$graph->Add($courbe);
119
		$graph->Add($courbe);
128
 
120
 
129
		return $graph;
121
		return $graph;
130
	}
122
	}
131
 
123
 
132
	public function combinerGraphiques($graph1, $graph2, $taille) {
124
	public function combinerGraphiques($graph1, $graph2, $taille) {
-
 
125
		include_once $this->chemin_lib_graph.'jpgraph_mgraph.php';
133
 
-
 
134
		include_once('lib/jpgraph_mgraph.php');
126
 
135
		$mgraph = new MGraph($taille[0],$taille[1],"auto");
127
		$mgraph = new MGraph($taille[0],$taille[1],"auto");
136
		$xpos1=300;$ypos1=3;
128
		$xpos1=300;$ypos1=3;
137
		$xpos2=3;$ypos2=200;
129
		$xpos2=3;$ypos2=200;
138
		
130
		
139
		$graph1->SetFrame(false);
131
		$graph1->SetFrame(false);
140
		$graph2->SetFrame(false);
132
		$graph2->SetFrame(false);
141
		
133
		
142
		//$xpos3=3;$ypos3=1000;
134
		//$xpos3=3;$ypos3=1000;
143
		$mgraph->Add($graph1,$xpos1,$ypos1);
135
		$mgraph->Add($graph1,$xpos1,$ypos1);
144
		$mgraph->Add($graph2,$xpos2,$ypos2);
136
		$mgraph->Add($graph2,$xpos2,$ypos2);
145
		$mgraph->SetShadow();
137
		$mgraph->SetShadow();
146
		//$mgraph->Add($graph['experience_bota'],$xpos3,$ypos3);
138
		//$mgraph->Add($graph['experience_bota'],$xpos3,$ypos3);
147
		return $mgraph;
139
		return $mgraph;
148
	}
140
	}
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
	}
144
	}
153
 
-
 
154
}
145
}
155
?>
146
?>
156
147