Rev 232 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*** PHP Version 5** @category PHP* @package annuaire* @author aurelien <aurelien@tela-botanica.org>* @copyright 2010 Tela-Botanica* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL* @version SVN: <svn_id>* @link /doc/annuaire/*/class Statistiques {const GRAPH_CAMEMBERT = 'pie';const GRAPH_COURBE = 'courbe';public function genererGraphique($type_graphique, $valeurs, $titre = '', $nom_axe_x = '', $nom_axe_y = '') {// Inclusion de la librairie JpGraphinclude_once("lib/jpgraph.php");$graph = null;switch($type_graphique) {case Statistiques::GRAPH_CAMEMBERT:$graph = $this->genererGraphiqueCamembert($valeurs, $titre);break;case Statistiques::GRAPH_COURBE:$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $nom_axe_x, $nom_axe_y);break;default:$graph = $this->genererGraphiqueCourbe($valeurs);break;}return $graph;}public function genererGraphiqueCamembert($valeurs, $titre) {include_once("lib/jpgraph_pie.php");$graph = new PieGraph(500,500);$oPie = new PiePlot(array_values($valeurs));$oPie->SetLegends(array_keys($valeurs));// Ajouter le titre du graphique$graph->title->Set($titre);// position du graphique (légèrement à droite)$oPie->SetCenter(0.4);$oPie->SetValueType(PIE_VALUE_PER);// Format des valeurs de type "entier"$oPie->value->SetFormat('%d');$graph->Add($oPie);return $graph/*->Stroke(_IMG_HANDLER)*/;}public function genererGraphiqueCourbe($valeurs, $titre, $nom_axe_x, $nom_axe_y) {include_once("lib/jpgraph_line.php");// Création du conteneur$graph = new Graph(500,500);// Fixer les marges$graph->img->SetMargin(40,30,50,40);// Lissage sur fond blanc (évite la pixellisation)$graph->img->SetAntiAliasing("white");// A détailler$graph->SetScale("textlin");// Ajouter une ombre$graph->SetShadow();// Ajouter le titre du graphique$graph->title->Set($titre);// Afficher la grille de l'axe des ordonnées$graph->ygrid->Show();// Fixer la couleur de l'axe (bleu avec transparence : @0.7)$graph->ygrid->SetColor('blue@0.7');// Des tirets pour les lignes$graph->ygrid->SetLineStyle('solid');// Afficher la grille de l'axe des abscisses$graph->xgrid->Show();// Fixer la couleur de l'axe (rouge avec transparence : @0.7)$graph->xgrid->SetColor('red@0.7');// Des tirets pour les lignes$graph->xgrid->SetLineStyle('solid');// Créer une courbes$courbe = new LinePlot(array_values($valeurs));// Chaque point de la courbe ****// Type de point$courbe->mark->SetType(MARK_FILLEDCIRCLE);// Couleur de remplissage$courbe->mark->SetFillColor("green");// Taille$courbe->mark->SetWidth(5);// Paramétrage des axes$graph->xaxis->title->Set($nom_axe_x);$graph->xaxis->SetTickLabels(array_keys($valeurs));// Paramétrage des axes$graph->yaxis->title->Set($nom_axe_y);// Ajouter la courbe au conteneur$graph->Add($courbe);return $graph/*->Stroke(_IMG_HANDLER)*/;}public function combinerGraphiques($graph) {include_once('lib/jpgraph_mgraph.php');$mgraph = new MGraph(2000,2000);$xpos1=3;$ypos1=3;$xpos2=3;$ypos2=500;$xpos3=3;$ypos3=1000;$mgraph->Add($graph['pays'],$xpos1,$ypos1);$mgraph->Add($graph['activite_bota'],$xpos2,$ypos2);$mgraph->Add($graph['experience_bota'],$xpos3,$ypos3);return $mgraph->Stroke(_IMG_HANDLER);}}?>