My PHP JpGraph code displays error like
The image "http://localhost/jpeg/src/Examples/x.php" cannot be displayed
because it contains error
When I search the post here and here, the main problem indicated was white space at the beginning or end or the problem with the header. But I could not find a whitespace (I hope the header is okAY because it's a simplest manual example).
Just for a try, I tried to save the image instead of display in browser. But it showed another problem as JpGraph Error: 25107 Can't write to file, php process has no permission. But I couldnot solve the second error after searching some source. I worry whether I go wrong path and doing some blind thing. Can anyone direct me?
I use the code to generate JpGraph:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
require_once('jpgraph/jpgraph.php');
require_once('jpgraph/jpgraph_matrix.php');
$data = array(
array(0,1,2,3,4,5,6,7,8,9,10),
array(10,9,8,7,6,5,4,3,2,1,0),
array(0,1,2,3,4,5,6,7,8,9,10),
array(10,9,8,17,6,5,4,3,2,1,0),
);
$graph = new MatrixGraph(400,300);
$graph->title->Set('Basic matrix example');
$graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
$mp = new MatrixPlot($data);
$graph->Add($mp);
//$graph->Stroke();
$graph->Stroke("myimage.png");
?>
I solved the problem. It was a problem due to whites space, but in some of the source files. Here are the two steps I followed to overcome the error,
In the php.ini file, set the output buffering as 0 instead of 4096.
In the source files (jpgraph_matrix.php and jpgraph_glayout_vh.inc.php), there were some extra white space at the beginning and at the end. When done the first step (set the buffer), the white space containing files and lines were displayed in browser. When those lines were removed, the graph is generated.