我有一组来自 JpGraph 的代码来帮助我创建条形图。
<?php
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_bar.php');
$datay=array(1992,1993,1995,1996,1997,1998,2001);
// Size of graph
$width=400;
$height=500;
// Set the basic parameters of the graph
$graph = new Graph($width,$height);
$graph->SetScale('textlin');
$top = 60;
$bottom = 30;
$left = 80;
$right = 30;
$graph->Set90AndMargin($left,$right,$top,$bottom);
// Nice shadow
$graph->SetShadow();
// Setup labels
$lbl = array("Andrew\nTait","Thomas\nAnderssen","Kevin\nSpacey","Nick\nDavidsson",
"David\nLindquist","Jason\nTait","Lorin\nPersson");
$graph->xaxis->SetTickLabels($lbl);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center','right');
// Label align for Y-axis
$graph->yaxis->SetLabelAlign('center','bottom');
// Titles
$graph->title->Set('Number of incidents');
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('orange');
$bplot->SetWidth(0.5);
$bplot->SetYMin(1990);
?>
但是,这只有在我把它放在我的代码顶部时才有效。如果我把它放在其他任何地方,它将无法显示。有什么办法可以克服这个问题,如果我把代码专门放在一个地方,例如它会出现在那里?此外,我将使用我自己的数据库中的一些数据作为该图的值。
谢谢你。