将从单独的php文件生成的数组传递给JPgraph

时间:2013-07-25 04:21:25

标签: php arrays post jpgraph

我在文件名“objective_matrix.php”中有三个名为$smty1; $thty2; $totaly3的php数组。

我想将这三个数组传递给名为graph2.php的Jpgraph文件,如下所示

<?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();
?>

在“objective_matrix.php”中,我正在使用以下方式绘制图形:
<img style="position:absolute; top:635px" src="graph2.php" />

我尝试使用URL方法传递这些数据,但我不知道如何在那里传递变量。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您的问题有一个简短的解决方案Harshanii .. 你可以在临时数据库中保存数组数据($ smty1,$ thty2,$ totaly3)并在graph2.php中调用这些数据..