[PHP][JPGraph] Setvaluepos / Show
Dans le cadre de mon travail, j’ai été amené à devoir ressortir des graphes de statistiques. Pour se faire, j’ai donc utilisé la librairie PHP jpGraph version 3.5.0b1 (http://jpgraph.net).
Je souhaitais avoir les valeurs des différentes barres en haut de ces dernières, malheureusement une petite coquille m’a valu quelques cheveux blancs supplémentaires.
Voici un code non fonctionnel :
<?php
// content="text/plain; charset=utf-8"
include ("./jpgraph/jpgraph.php");
include ("./jpgraph/jpgraph_bar.php");
$datay=array(12,8,19,3,10,5);
// Create the graph. These two calls are always required
$graph = new Graph(600,400);
$graph->SetScale('textlin');
$bplot = new BarPlot($datay);
$bplot->value->Show();
$graph->Add($bplot);
$graph->Stroke();
?>
et un code fonctionnel
<?php
// content="text/plain; charset=utf-8"
include ("./jpgraph/jpgraph.php");
include ("./jpgraph/jpgraph_bar.php");
$datay=array(12,8,19,3,10,5);
// Create the graph. These two calls are always required
$graph = new Graph(600,400);
$graph->SetScale('textlin');
$bplot = new BarPlot($datay);
$graph->Add($bplot);
$bplot->value->Show();
$graph->Stroke();
?>
La différence : l’ordre des instructions !
La fonction $bplot->value->Show () doit être exécutée une fois l’élément (ici le diagramme en barre) ajouté au graphe.
Accueil > Linux > Développement > [PHP][JPGraph] Setvaluepos / Show