OVH Cloud OVH Cloud

test JpGraph et session

3 réponses
Avatar
Rene Bantegnie
Bonjour

J'utilise JpGraph pour afficher des graphes
Pour passer les paramètres du graphe, j'utilise une session
Lorsque je n'affiche qu'un graphe dans ma page c'est bon
Par contre lorsque je veux afficher plusieurs graphes différents
en modifiant avant chaque appel les variables de session
j'affiche pour chaque appel le dernier graphe
Cela veut-il dire que ma page n'est pas traitée dans l'ordre de son
écriture. Les appels à ma page de construction de mes dessins
seraient-ils traités en fin du script principal et ainsi hériteraient des
derniers valeurs de mes variables de sessions ??
Merci de votre aide
--
René

Ci-dessous les pages en question
.................................
<?
// demarrage de la session
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<meta NAME="robots" CONTENT="noindex,nofollow">

<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">

<meta HTTP-EQUIV="Expires" content="Jan 1, 1980">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<head>
<title>TEST Histogramme</title>
</head>
<body>
<?
$niv=array("n6","n5","n4","n3","n2","n1","n0","n00");

$_SESSION['y1']= array(10,50,60,5,4);
$_SESSION['y2']= array(5,45,55,20,56);
$_SESSION['x']= array("n1","n2","n3","n5","n6");
$_SESSION['xtitre']="niveau";
$_SESSION['ytitre']="nb";
$_SESSION['legend1y']="formation";
$_SESSION['legend2y']="explo";
$_SESSION['color']="2";
$_SESSION['titre']="Nombre de plongées par niveau";
echo "<br>".$_SESSION['titre']."<br>";
echo "<br><img src='histogramme.php?dummy=".time()."'>";

$_SESSION['y1']= array(51,66,47,5,4,21,15);
$_SESSION['y2']= array(25,5,45,6,7,23,8);
$_SESSION['x']= array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
$_SESSION['xtitre']="jour";
$_SESSION['ytitre']="nb";
$_SESSION['legend1y']="cote";
$_SESSION['legend2y']="bateau";
$_SESSION['color']="1";
$_SESSION['titre']="Nombre de sorties en fonction du jour de la semaine";
echo "<br>".$_SESSION['titre']."<br>";
echo "<br><img src='histogramme.php?dummy=".time()."'>";
?>

</body>
</html>

..............

<?
// demarrage de la session
session_start();


include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");

$dataB="";
$dataH="";
$datax="";
$legendB="";
$legendH="";

$dataB=$_SESSION['y2'];
$dataH=$_SESSION['y1'];
$datax=$_SESSION['x'];

$legendB=$_SESSION['legend2y'];
$legendH=$_SESSION['legend1y'];
if ($_SESSION['color']=="1"){
$colorB1="blue";
$colorB2="aqua";
$colorH1="orange";
$colorH2="yellow";
}elseif ($_SESSION['color']=="2"){
$colorB1="cyan4";
$colorB2="cyan";
$colorH1="bisque4";
$colorH2="bisque";
}

$xtitre=$_SESSION['xtitre'];
$ytitre=$_SESSION['ytitre'];
$titre=$_SESSION['titre'];

// Create the graph. These two calls are always required
$graph = new Graph(600,300,"auto");
$graph->SetScale("textlin");

$graph->SetShadow();
// img->SetMargin(gauche,droite,haut,bas);
$graph->img->SetMargin(40,100,20,40);
$graph->SetMarginColor('white');

// Create the bar plots
$b1plot = new BarPlot($dataB);
$b1plot->SetFillGradient($colorB1,$colorB2,GRAD_HOR);
$b1plot->SetFillColor($colorB1);
$b1plot->SetLegend($legendB);
$b2plot = new BarPlot($dataH);
$b2plot->SetFillGradient($colorH1,$colorH2,GRAD_HOR);
$b2plot->SetColor($colorH1);
$b2plot->SetLegend($legendH);

// Create the grouped bar plot
//$gbplot = new GroupBarPlot(array($b1plot,$b2plot));

// Create the accumulated bar plot
$gbplot = new AccBarPlot(array($b1plot,$b2plot));

// ...and add it to the graPH
$graph->Add($gbplot);

$graph->xaxis->SetTickLabels($datax);


$graph->title->Set($titre);
$graph->xaxis->title->Set($xtitre);
$graph->yaxis->title->Set($ytitre);

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

$graph->legend->SetShadow('gray@0.4',5);
$graph->legend->SetPos(0.03,0.05,'right','top');


// Display the graph
$graph->Stroke();
?>

3 réponses

Avatar
jean
Le 30.11.2003 21:01, Rene Bantegnie nous contait :

Bonjour

J'utilise JpGraph pour afficher des graphes
Pour passer les paramètres du graphe, j'utilise une session
Lorsque je n'affiche qu'un graphe dans ma page c'est bon
Par contre lorsque je veux afficher plusieurs graphes différents
en modifiant avant chaque appel les variables de session
j'affiche pour chaque appel le dernier graphe
Cela veut-il dire que ma page n'est pas traitée dans l'ordre de son
écriture. Les appels à ma page de construction de mes dessins
seraient-ils traités en fin du script principal et ainsi hériteraient des
derniers valeurs de mes variables de sessions ??
Merci de votre aide


Avatar
Ludwig BECK
Le 30.11.2003 21:01, Rene Bantegnie nous contait :

Bonjour

J'utilise JpGraph pour afficher des graphes
Pour passer les paramètres du graphe, j'utilise une session
Lorsque je n'affiche qu'un graphe dans ma page c'est bon
Par contre lorsque je veux afficher plusieurs graphes différents
en modifiant avant chaque appel les variables de session
j'affiche pour chaque appel le dernier graphe
Cela veut-il dire que ma page n'est pas traitée dans l'ordre de son
écriture. Les appels à ma page de construction de mes dessins
seraient-ils traités en fin du script principal et ainsi hériteraient des
derniers valeurs de mes variables de sessions ??
Merci de votre aide



--
*BOYCOTTONS FREE.FR* , pour eux la liberté n'est qu'un slogan:
http://www.boycott-free.fr.st

:-) :-p :-D :-* 8-) O:-) ;-) :- :-[ =-O :-( :'( >:o :-! :-X :-$

Avatar
Rene Bantegnie
On Sun, 30 Nov 2003 21:08:39 +0100, jean wrote:


Où est passé mon test ???
--
René