New file |
0,0 → 1,148 |
<?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_appartenance_asso.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(0) ; |
$annee_debut = 2002; |
$mois = 4; |
$annee = 2002; |
$tps_debut = mktime(0,0,0,$mois,1,$annee); |
$tps_courrant = $tps_debut; |
$tps_fin = mktime(0, 0, 0, date('m'), 0);// dernier jour du mois précedent le mois courrant |
//Requete par mois |
$i = 0; |
while ($tps_courrant <= $tps_fin) { |
if (($mois)/12 > 1) { |
$mois = 1; |
$annee = $annee+1; |
} |
$tps_mois_suivant = mktime(0,0,0,$mois+1,1,$annee); |
//echo date('Y-m-d H:i:s', $tps_courrant).' - '.date('Y-m-d H:i:s', $tps_mois_suivant); |
$requete = 'SELECT ID_LABEL_ASS, COUNT( U_ASS ) AS nbre, LABEL_ASS '. |
'FROM annuaire_tela, annuaire_LABEL_ASS '. |
'WHERE U_DATE >= "'.date('Y-m-d H:i:s', $tps_courrant).'" '. |
'AND U_NIV = ID_LABEL_ASS '. |
'AND U_DATE < "'.date('Y-m-d H:i:s', $tps_mois_suivant).'" '. |
'GROUP BY ID_LABEL_ASS '; |
$resultat = $db->query($requete) ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$id = $ligne->ID_LABEL_ASS; |
$legende_libelle = $ligne->LABEL_ASS; |
$tab_donnees[$id][$i] = $tab_donnees[$id][$i-1] + $ligne->nbre; |
if (!isset($legende[$id])) { |
$tab_legende[$id] = $legende_libelle; |
} |
} |
//echo ' - '.$resultat->numRows().'<br/>'; |
$tab_legende_axe_x[$i] = $tab_mois[$mois-1].' '.$annee; |
$tps_courrant = $tps_mois_suivant; |
$mois++; |
$i++; |
} |
//echo '<pre>'.print_r($tab_donnees, true).'</pre>'; |
|
$graph = new Graph(500, 490, 'auto'); |
$graph->img->SetMargin(50, 30, 50, 100); |
$graph->SetMarginColor('white'); |
$graph->SetScale('textint'); |
$graph->xaxis->SetTickLabels($tab_legende_axe_x); |
$graph->xaxis->SetLabelAngle(90); |
$graph->xaxis->SetTextLabelInterval(4); |
$graph->SetShadow(); |
$graph->title->Set("Évolution de l'appartenance a une association au ".date('d-m-Y', $tps_fin)); |
$graph->title->SetFont(FF_FONT1,FS_BOLD); |
$graph->legend->SetLayout(LEGEND_VERT); |
$graph->legend->Pos(0.15, 0.10, 'left', 'top'); |
|
$txt = new Text('Mois depuis le 1er avril 2002', 270, 460); |
$graph->AddText($txt); |
|
// Création des lignes |
$p1 = new LinePlot($tab_donnees[1]); // Oui |
$p2 = new LinePlot($tab_donnees[2]); // Non |
$p3 = new LinePlot($tab_donnees[3]); // Ne se prononce pas |
|
// Attribution des couleurs |
$p1->SetFillColor('green'); |
$p2->SetFillColor('red'); |
$p3->SetFillColor('white'); |
|
// Attribution des textes pour la légende |
$p1->SetLegend($tab_legende[1]); |
$p2->SetLegend($tab_legende[2]); |
$p3->SetLegend($tab_legende[3]); |
|
// Nous ajoutons ensemble les lignes |
$ap = new AccLinePlot(array($p3, $p2, $p1)); |
|
// Add the accumulated line plot to the graph |
$graph->Add($ap); |
$graph->Stroke(); |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log$ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |