Question

I have three php arrays named $smty1; $thty2; $totaly3 in a file name "objective_matrix.php".

I want to pass these three arrays to the Jpgraph file named graph2.php which is shown below

<?php
 require_once('/jpgraph-3.5.0b1/src/jpgraph.php');
 require_once('/jpgraph-3.5.0b1/src/jpgraph_bar.php'); 

//In here I will need the arrays $smty1, $thty2, $totaly3


$graph = new Graph(450,200,'auto');    
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,40,40);
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());

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

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

$bplot1 = new BarPlot($smty1);
$bplot2 = new BarPlot($thty2);
$bplot3 = new BarPlot($totaly3);

$bplot1->SetFillColor("orange");
$bplot2->SetFillColor("brown");
$bplot3->SetFillColor("darkgreen");

$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();

$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();

$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);

$graph->Stroke();
?>

In "objective_matrix.php" I'm plotting the graph using:
<img style="position:absolute; top:635px" src="graph2.php" />

I tried using the URL method to pass these data but I don't know how to pass a variable there. Can somebody please help me?

Was it helpful?

Solution

There is a short solution for your problem Harshanii.. you can save array data ($smty1, $thty2, $totaly3) in temporary database and recall those data in the graph2.php ..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top