16,7 → 16,7 |
const GRAPH_CAMEMBERT = 'pie'; |
const GRAPH_COURBE = 'courbe'; |
|
public function genererGraphique($type_graphique, $valeurs, $titre = '', $nom_axe_x = '', $nom_axe_y = '') { |
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"); |
24,11 → 24,11 |
|
switch($type_graphique) { |
case Statistiques::GRAPH_CAMEMBERT: |
$graph = $this->genererGraphiqueCamembert($valeurs, $titre); |
$graph = $this->genererGraphiqueCamembert($valeurs, $titre, $taille); |
break; |
|
case Statistiques::GRAPH_COURBE: |
$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $nom_axe_x, $nom_axe_y); |
$graph = $this->genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y); |
break; |
|
default: |
39,10 → 39,10 |
return $graph; |
} |
|
public function genererGraphiqueCamembert($valeurs, $titre) { |
public function genererGraphiqueCamembert($valeurs, $titre, $taille) { |
|
include_once("lib/jpgraph_pie.php"); |
$graph = new PieGraph(800,500); |
$graph = new PieGraph($taille[0],$taille[1]); |
|
$legendes = array_keys($valeurs); |
|
55,7 → 55,7 |
$graph->title->Set($titre); |
|
// position du graphique (légèrement à droite) |
$oPie->SetCenter(0.4); |
$oPie->SetCenter(0.35); |
|
$oPie->SetValueType(PIE_VALUE_PER); |
|
63,21 → 63,21 |
$oPie->value->SetFormat('%1.2f%%'); |
|
$graph->Add($oPie); |
return $graph->Stroke(_IMG_HANDLER); |
return $graph; |
} |
|
public function genererGraphiqueCourbe($valeurs, $titre, $nom_axe_x, $nom_axe_y) { |
public function genererGraphiqueCourbe($valeurs, $titre, $taille, $nom_axe_x, $nom_axe_y) { |
|
include_once("lib/jpgraph_line.php"); |
|
// Création du conteneur |
$graph = new Graph(800,500); |
$graph = new Graph($taille[0],$taille[1],"auto"); |
|
// Fixer les marges |
$graph->img->SetMargin(40,30,50,40); |
$graph->img->SetMargin(50,30,50,100); |
|
// Lissage sur fond blanc (évite la pixellisation) |
$graph->img->SetAntiAliasing("white"); |
$graph->SetMarginColor("white"); |
|
// A détailler |
$graph->SetScale("textlin"); |
91,16 → 91,18 |
// 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'); |
$graph->ygrid->SetColor('#E6E6E6@0.7'); |
// Des tirets pour les lignes |
$graph->ygrid->SetLineStyle('solid'); |
|
// Afficher la grille de l'axe des abscisses |
$graph->xgrid->Show(); |
//$graph->xgrid->Show(); |
// Fixer la couleur de l'axe (rouge avec transparence : @0.7) |
$graph->xgrid->SetColor('red@0.7'); |
//$graph->xgrid->SetColor('red@0.7'); |
// Des tirets pour les lignes |
$graph->xgrid->SetLineStyle('solid'); |
//$graph->xgrid->SetLineStyle('solid'); |
$graph->xaxis->SetLabelAngle(90); |
$graph->xaxis->SetTextLabelInterval(4); |
|
// Créer une courbes |
$courbe = new LinePlot(array_values($valeurs)); |
109,12 → 111,13 |
// Type de point |
$courbe->mark->SetType(MARK_FILLEDCIRCLE); |
// Couleur de remplissage |
$courbe->mark->SetFillColor("green"); |
$courbe->mark->SetFillColor("red"); |
// Taille |
$courbe->mark->SetWidth(5); |
$courbe->mark->SetWidth(1); |
|
// Paramétrage des axes |
$graph->xaxis->title->Set($nom_axe_x); |
//$graph->xaxis->title->Set($nom_axe_x); |
$txt = new Text($nom_axe_x,270,460); |
$graph->xaxis->SetTickLabels(array_keys($valeurs)); |
|
// Paramétrage des axes |
123,21 → 126,30 |
// Ajouter la courbe au conteneur |
$graph->Add($courbe); |
|
return $graph->Stroke(_IMG_HANDLER); |
return $graph; |
} |
|
public function combinerGraphiques($graph) { |
public function combinerGraphiques($graph1, $graph2, $taille) { |
|
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); |
$mgraph = new MGraph($taille[0],$taille[1],"auto"); |
$xpos1=300;$ypos1=3; |
$xpos2=3;$ypos2=200; |
|
$graph1->SetFrame(false); |
$graph2->SetFrame(false); |
|
//$xpos3=3;$ypos3=1000; |
$mgraph->Add($graph1,$xpos1,$ypos1); |
$mgraph->Add($graph2,$xpos2,$ypos2); |
$mgraph->SetShadow(); |
//$mgraph->Add($graph['experience_bota'],$xpos3,$ypos3); |
return $mgraph; |
} |
|
public function dessinerGraph($graph) { |
return $graph->Stroke(_IMG_HANDLER); |
} |
|
} |
?> |