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_continent.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
 
47
// Inclusion du fichier de configuration de Papyrus
48
include '../../../../papyrus/configuration/pap_config.inc.php';
49
 
50
// Inclusion de la bibliothèque PEAR DB nécessaire
51
include 'DB.php';
52
 
53
// +------------------------------------------------------------------------------------------------------+
54
// |                                            CORPS du PROGRAMME                                        |
55
// +------------------------------------------------------------------------------------------------------+
56
 
57
// Connexion à la base de données
58
$db = DB::connect(PAP_DSN) ;
59
if (DB::isError($db)) {
60
    echo 'Message Standard         : ' . $db->getMessage() . "\n";
61
    echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
62
    echo 'Message DBMS/Déboguage   : ' . $db->getDebugInfo() . "\n";
63
    exit;
64
}
65
 
66
// Initialisation des variables
67
$tab_legende = array();
68
$tab_donnees = array() ;
69
 
70
 
71
// Recherche des données
72
$requete = 	'SELECT CC_ID_Continent, CC_Intitule_continent, COUNT(CC_ID_Continent) AS nbre '.
73
			'FROM annuaire_tela, carto_PAYS, carto_CONTINENT '.
74
			'WHERE U_COUNTRY = CP_ID_Pays '.
75
			'AND CP_ID_Continent = CC_ID_Continent '.
76
			'GROUP BY CC_ID_Continent ';
77
 
78
$resultat = $db->query($requete) ;
79
 
80
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
81
	$id = $ligne->CC_ID_Continent;
82
    $legende_libelle = '['.$id.'] '.$ligne->CC_Intitule_continent.' (%1.2f%%)';
83
    $tab_donnees[$id] = $ligne->nbre;
84
    if (!isset($legende[$id])) {
85
    	$tab_legende[$id] = $legende_libelle;
86
    }
87
}
88
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
89
//echo '<pre>'.print_r($tab_legende, true).'</pre>';
90
 
91
$graph  = new PieGraph(500, 490, 'camembert_distribution_par_continent.png', 3600);
92
 
93
$graph->SetShadow();
94
$graph->title->Set('Distribution des inscrits par continents');
95
$graph->title->SetFont(FF_FONT1,FS_BOLD);
96
$graph->legend->Pos(0.02, 0.10, 'right', 'top');
97
 
98
$p1 = new PiePlot($tab_donnees);
99
$p1->SetLegends($tab_legende);
100
$p1->SetCenter(0.32);
101
$p1->SetStartAngle(290);
102
$p1->SetLabelType(PIE_VALUE_PER);
103
$p1->value->SetFormat('%1.2f%%');
104
//$p1->SetLabels($tab_legende);
105
$p1->ExplodeSlice(6);
106
$p1->ExplodeSlice(7);
107
 
108
$graph->Add($p1);
109
$graph->Stroke();
110
 
111
/* +--Fin du code ----------------------------------------------------------------------------------------+
112
*
113
* $Log$
114
*
115
* +-- Fin du code ----------------------------------------------------------------------------------------+
116
*/
117
?>