Blame | Last modification | View Log | RSS feed
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 5.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of tela_botanica_v4. |
// | |
// | tela_botanica_v4 is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | tela_botanica_v4 is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* tela_botanica_v4 - graph_distribution_continent.php
*
* Description :
*
*@package tela_botanica_v4
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 1999-2007
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
// Inclusion des fichiers jpgraph nécessaires
include '../../../../api/jpgraph_2.1.4/jpgraph.php';
include '../../../../api/jpgraph_2.1.4/jpgraph_pie.php';
// Inclusion du fichier de configuration de Papyrus
include '../../../../papyrus/configuration/pap_config.inc.php';
// Inclusion de la bibliothèque PEAR DB nécessaire
include 'DB.php';
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
// Connexion à la base de données
$db = DB::connect(PAP_DSN) ;
if (DB::isError($db)) {
echo 'Message Standard : ' . $db->getMessage() . "\n";
echo 'Message DBMS/Utilisateur : ' . $db->getUserInfo() . "\n";
echo 'Message DBMS/Déboguage : ' . $db->getDebugInfo() . "\n";
exit;
}
// Initialisation des variables
$tab_legende = array();
$tab_donnees = array() ;
// Recherche des données
$requete = 'SELECT CC_ID_Continent, CC_Intitule_continent, COUNT(CC_ID_Continent) AS nbre '.
'FROM annuaire_tela, carto_PAYS, carto_CONTINENT '.
'WHERE U_COUNTRY = CP_ID_Pays '.
'AND CP_ID_Continent = CC_ID_Continent '.
'GROUP BY CC_ID_Continent ';
$resultat = $db->query($requete) ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$id = $ligne->CC_ID_Continent;
$legende_libelle = '['.$id.'] '.$ligne->CC_Intitule_continent.' (%1.2f%%)';
$tab_donnees[$id] = $ligne->nbre;
if (!isset($legende[$id])) {
$tab_legende[$id] = $legende_libelle;
}
}
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
//echo '<pre>'.print_r($tab_legende, true).'</pre>';
$graph = new PieGraph(500, 490, 'camembert_distribution_par_continent.png', 3600);
$graph->SetShadow();
$graph->title->Set('Distribution des inscrits par continents');
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->legend->Pos(0.02, 0.10, 'right', 'top');
$p1 = new PiePlot($tab_donnees);
$p1->SetLegends($tab_legende);
$p1->SetCenter(0.32);
$p1->SetStartAngle(290);
$p1->SetLabelType(PIE_VALUE_PER);
$p1->value->SetFormat('%1.2f%%');
//$p1->SetLabels($tab_legende);
$p1->ExplodeSlice(6);
$p1->ExplodeSlice(7);
$graph->Add($p1);
$graph->Stroke();
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>