Subversion Repositories Applications.annuaire

Compare Revisions

Ignore whitespace Rev 441 → Rev 442

/trunk/composants/statistiques/Statistiques.php
15,25 → 15,25
 
const GRAPH_CAMEMBERT = 'pie';
const GRAPH_COURBE = 'courbe';
private $chemin_lib_graph = '';
public function __construct() {
$this->chemin_lib_graph = Config::get('chemin_jpgraph');
}
 
public function genererGraphique($type_graphique, $valeurs, $titre = '', $taille = array(800, 800), $nom_axe_x = '', $nom_axe_y = '') {
 
// Inclusion de la librairie JpGraph
include_once("lib/jpgraph.php");
include_once $this->chemin_lib_graph.'jpgraph.php';
$graph = null;
 
switch($type_graphique) {
case Statistiques::GRAPH_CAMEMBERT:
$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille);
break;
 
break;
case Statistiques::GRAPH_COURBE:
$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y);
break;
 
break;
default:
$graph = $this->genererGraphiqueCourbe($valeurs);
break;
}
 
return $graph;
40,36 → 40,28
}
 
public function genererGraphiqueCamembert($valeurs, $titre, $taille) {
 
include_once("lib/jpgraph_pie.php");
$graph = new PieGraph($taille[0],$taille[1]);
include_once $this->chemin_lib_graph.'jpgraph_pie.php';
$legendes = array_keys($valeurs);
$valeurs = array_values($valeurs);
 
//die('<pre>'.print_r($valeurs, true).'</pre>');
$oPie = new PiePlot($valeurs);
$oPie->SetLegends($legendes);
 
// Ajouter le titre du graphique
$graph->title->Set($titre);
 
// position du graphique (légèrement à droite)
$oPie->SetCenter(0.35);
 
$oPie->SetValueType(PIE_VALUE_PER);
 
// Format des valeurs de type "entier"
$oPie->value->SetFormat('%1.2f%%');
 
$graph = new PieGraph($taille[0],$taille[1]);
// Ajouter le titre du graphique
$graph->title->Set($titre);
$graph->Add($oPie);
return $graph;
}
 
public function genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y) {
 
include_once("lib/jpgraph_line.php");
 
include_once $this->chemin_lib_graph.'jpgraph_line.php';
// Création du conteneur
$graph = new Graph($taille[0],$taille[1],"auto");
 
130,8 → 122,8
}
 
public function combinerGraphiques($graph1, $graph2, $taille) {
include_once $this->chemin_lib_graph.'jpgraph_mgraph.php';
 
include_once('lib/jpgraph_mgraph.php');
$mgraph = new MGraph($taille[0],$taille[1],"auto");
$xpos1=300;$ypos1=3;
$xpos2=3;$ypos2=200;
150,6 → 142,5
public function dessinerGraph($graph) {
return $graph->Stroke(_IMG_HANDLER);
}
 
}
?>
?>