Subversion Repositories Sites.tela-botanica.org

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
299 jpm 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 5.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org)                                    |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of tela_botanica_v4.                                                                         |
9
// |                                                                                                      |
10
// | tela_botanica_v4 is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | tela_botanica_v4 is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id$
25
/**
26
* tela_botanica_v4 - graph_distribution_europe.php
27
*
28
* Description :
29
*
30
*@package tela_botanica_v4
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 1999-2007
36
*@version       $Revision$ $Date$
37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
// Inclusion des fichiers jpgraph nécessaires
44
include '../../../../api/jpgraph_2.1.4/jpgraph.php';
45
include '../../../../api/jpgraph_2.1.4/jpgraph_pie.php';
46
include '../../../../api/jpgraph_2.1.4/jpgraph_pie3d.php';
47
 
48
// Inclusion du fichier de configuration de Papyrus
49
include '../../../../papyrus/configuration/pap_config.inc.php';
50
 
51
// Inclusion de la bibliothèque PEAR DB nécessaire
52
include 'DB.php';
53
 
54
// +------------------------------------------------------------------------------------------------------+
55
// |                                            CORPS du PROGRAMME                                        |
56
// +------------------------------------------------------------------------------------------------------+
57
 
58
// Connexion à la base de données
59
$db = DB::connect(PAP_DSN) ;
60
if (DB::isError($db)) {
61
    echo 'Message Standard         : ' . $db->getMessage() . "\n";
62
    echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
63
    echo 'Message DBMS/Déboguage   : ' . $db->getDebugInfo() . "\n";
64
    exit;
65
}
66
 
67
// Initialisation des variables
68
$tab_legende_fr = array();
69
$tab_legende_ss_fr = array();
70
$tab_donnees_fr = array() ;
71
$tab_donnees_ss_fr = array() ;
72
$total_autre = 0;
73
 
74
// Recherche des données
75
$requete = 	'SELECT CP_ID_Pays, CP_Intitule_pays, COUNT(CP_ID_Pays) AS nbre '.
76
			'FROM annuaire_tela, carto_PAYS '.
77
			'WHERE U_COUNTRY = CP_ID_Pays '.
78
			'AND CP_ID_Continent = 4 '.
79
			'GROUP BY CP_ID_Pays '.
80
			'ORDER BY nbre DESC';
81
 
82
$resultat = $db->query($requete) ;
83
 
84
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
85
	$id = $ligne->CP_ID_Pays;
86
    $legende_libelle = $ligne->CP_Intitule_pays.' (%1.2f%%)';
87
    if ($id != 'fr' && $id != 'FR') {
88
    	$tab_donnees_ss_fr[] = $ligne->nbre;
89
    	$tab_legende_ss_fr[] = $legende_libelle;
90
    	$total_autre += $ligne->nbre;
91
    } else {
92
    	$tab_donnees_fr[] = $ligne->nbre;
93
    	$tab_legende_fr[] = $legende_libelle;
94
    }
95
}
96
$tab_donnees_fr[] = $total_autre;
97
$tab_legende_fr[] = 'Autres pays européens (%1.2f%%)';
98
 
99
//echo '<pre>'.print_r($tab_donnees_ss_fr, true).'</pre>';
100
//echo '<pre>'.print_r($tab_legende, true).'</pre>';
101
 
102
$graph  = new PieGraph(510, 700, 'camembert_distribution_europe.png', 3600);
103
 
104
$graph->SetShadow();
105
$graph->title->Set('Distribution des inscrits en Europe');
106
$graph->title->SetFont(FF_FONT1,FS_BOLD);
107
$graph->legend->Pos(0.02, 0.10, 'right', 'top');
108
 
109
$p1 = new PiePlot($tab_donnees_fr);
110
$p1->setStartAngle(180);
111
$p1->SetSize(0.15);
112
$p1->SetCenter(0.60, 0.15);
113
//$p1->SetLegends($tab_legende_fr);
114
$p1->SetLabelType(PIE_VALUE_PER);
115
//$p1->value->SetFormat('%1.2f%%');
116
$p1->SetLabels($tab_legende_fr);
117
//$p1->title->Set('France');
118
$p1->SetLabelPos(1);
119
 
120
$p2 = new PiePlot($tab_donnees_ss_fr);
121
$p2->setStartAngle(180);
122
$p2->SetSize(0.22);
123
$p2->SetCenter(0.60, 0.75);
124
//$p2->SetLegends($tab_legende_ss_fr);
125
$p2->SetLabelType(PIE_VALUE_PER);
126
//$p2->value->SetFormat('%1.2f%%');
127
$p2->SetLabels($tab_legende_ss_fr);
128
$p2->title->Set('Détails des "autres pays"');
129
$p2->title->SetMargin(20);
130
$p2->SetLabelPos(1);
131
 
132
$graph->Add($p1);
133
$graph->Add($p2);
134
$graph->Stroke();
135
 
136
/* +--Fin du code ----------------------------------------------------------------------------------------+
137
*
138
* $Log$
139
*
140
* +-- Fin du code ----------------------------------------------------------------------------------------+
141
*/
142
?>