I am using PHP Jpgraph library to create a graph from arrays generated from a mysql query.
I have written this php code:
require_once('jpgraph/src/jpgraph.php');
require_once('jpgraph/src/jpgraph_bar.php');
foreach ($results as $key => $value){
$data[] = $value['num_rows'];//$data = array(740,902,647,208);
$data1[] = $value['department_name'];//$data1 = array('Epi', 'Dss', 'Bio', 'Clin');
}
$graph = new Graph(450,200,"auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(40,30,40,40);
$graph->SetShadow();
$graph->xaxis->SetTickLabels($data1);
$bplot = new BarPlot($data);
$bplot->SetFillColor("lightgreen");
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetColor("black","navy");
$graph->Add($bplot);
$graph->Stroke();
I expect a bargraph generated by jpgraph. However, i get a blank page with a message "The image 'http://localhost/KVL/showgraph" cannot be displayed because it contains errors. I have run php -m
on my terminal and can see that GD extension is installed. I am running php 7.2
.