Subversion Repositories Applications.annuaire

Rev

Rev 223 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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