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. |
// | |
// | Foobar 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. |
// | |
// | Foobar 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_niveau_bota.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 |
// +------------------------------------------------------------------------------------------------------+
include ("../../../../api/jpgraph_1.12.2/jpgraph.php") ;
include ("../../../../api/jpgraph_1.12.2/jpgraph_line.php") ;
include ("../../../../api/jpgraph_1.12.2/jpgraph_bar.php");
include ("../../../../papyrus/configuration/pap_config.inc.php") ;
include_once 'DB.php' ;
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
$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;
}
$tab_mois = array('Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Dec');
$tab_legende_axe_x = array('');
$tab_legende = array();
$tab_donnees = array() ;
$tab_donnees_max = array();
$annee = 2002;
$tps_debut = mktime(0,0,0,1,1,$annee);
$tps_courrant = $tps_debut;
$tps_fin = mktime(0,0,0,0,0);// dernier jour du mois précedent le mois courrant
//Requete par mois
$i = 0;
while ($tps_courrant <= $tps_fin) {
$tps_suivant = mktime(0,0,0,1,1,$annee+1);
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_suivant);
$requete = 'SELECT ID_LABEL_NIV, COUNT( U_NIV ) AS nbre, LABEL_NIV '.
'FROM annuaire_tela, annuaire_LABEL_NIV '.
'WHERE U_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '.
'AND U_NIV = ID_LABEL_NIV '.
'AND U_DATE < "'.date('Y-m-d H:i:s', $tps_suivant).'" '.
'GROUP BY ID_LABEL_NIV ';
$resultat = $db->query($requete) ;
$tab_donnees_max[$i] = 0;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$tab_donnees[$ligne->ID_LABEL_NIV][$i] = $ligne->nbre;
$tab_donnees_max[$i] += $ligne->nbre;
if (!isset($legende[$ligne->ID_LABEL_NIV])) {
$tab_legende[$ligne->ID_LABEL_NIV] = $ligne->LABEL_NIV;
}
}
//echo ' - '.$resultat->numRows().'<br/>';
$tab_legende_axe_x[$i] = $annee;
$tps_courrant = $tps_suivant;
$annee++;
$i++;
}
//echo '<pre>'.print_r($tab_donnees, true).'</pre>';
foreach ($tab_donnees as $cle1 => $niveaux) {
foreach ($niveaux as $cle2 => $quantite) {
$tab_donnees[$cle1][$cle2] = $quantite/$tab_donnees_max[$cle2]*100;
}
}
$graph = new Graph(500, 550, 'auto');
$graph->img->SetMargin(50, 30, 50, 150);
$graph->SetMarginColor('white');
$graph->SetScale('textint');
$graph->xaxis->SetTickLabels($tab_legende_axe_x);
$graph->xaxis->SetLabelAngle(90);
$graph->SetShadow();
$graph->title->Set("Évolution du niveau en botanique des inscrits au Réseau au ".date('d-m-Y', $tps_fin));
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->legend->SetLayout(LEGEND_VERT);
$graph->legend->Pos(0.10, 0.80, 'left', 'top');
$txt = new Text('Années', 400, 450);
$graph->AddText($txt);
// Création des lignes
$p1 = new BarPlot($tab_donnees[1]); // Débutant
$p1->value->Show();
$p1->value->SetFormat('%01.0f%%');
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p2 = new BarPlot($tab_donnees[2]); // Ayant une bonne pratique
$p2->value->Show();
$p2->value->SetFormat('%01.0f%%');
$p2->value->SetFont(FF_FONT1,FS_BOLD);
$p3 = new BarPlot($tab_donnees[3]); // Confirmé
$p3->value->Show();
$p3->value->SetFont(FF_FONT1,FS_BOLD);
$p3->value->SetFormat('%01.0f%%');
$p4 = new BarPlot($tab_donnees[4]); // Ne se prononce pas
$p4->value->Show();
$p4->value->SetFormat('%01.0f%%');
$p4->value->SetFont(FF_FONT1,FS_BOLD);
// Attribution des couleurs
$p1->SetFillColor('#cc3333');
$p2->SetFillColor('#c3d9ff');
$p3->SetFillColor('green');
$p4->SetFillColor('white');
// Attribution des textes pour la légende
$p1->SetLegend($tab_legende[1]);
$p2->SetLegend($tab_legende[2]);
$p3->SetLegend($tab_legende[3]);
$p4->SetLegend($tab_legende[4]);
// Nous ajoutons ensemble les lignes
$ap = new AccBarPlot(array($p4, $p3, $p2, $p1));
// Add the accumulated line plot to the graph
$graph->Add($ap);
$graph->Stroke();
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>