Kod wygląda tak który nie działa na mojej stronce a działa jak go wrzucę do pliki index.php:
require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_line.php");
require_once ("jpgraph/jpgraph_bar.php");
function readsunspotdata($aFile, &$aYears, &$aSunspots) {
$lines = @file($aFile,FILE_IGNORE_NEW_LINES
|FILE_SKIP_EMPTY_LINES
); if( $lines === false ) {
throw new JpGraphException('Can not read sunspot data file.');
}
foreach( $lines as $line => $datarow ) {
$aSunspots[] = trim($split[1
]); }
}
readsunspotdata('dane.txt',$year,$ydata);
$width = 600; $height = 200;
$graph = new Graph($width,$height);
$graph->SetScale('intint');
$graph->title->Set('Sunspot example');
$graph->xaxis->title->Set('(year from 1701)');
$graph->yaxis->title->Set('(# sunspots)');
$lineplot=new LinePlot($ydata);
$lineplot->SetFillColor('orange@0.5');
$graph->Add($lineplot);
$graph->Stroke();
Próbowałem też skrypt który korzysta z GD i te same objawy.
O to kod:
$im=imagecreatetruecolor( 300, 200);
$black=imagecolorallocate($im, 0, 0, 0);
$lightgray=imagecolorallocate($im, 230, 230, 230);
$darkgreen=imagecolorallocate($im, 80, 140, 80);
$white=imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im,0,0,299,199 ,$lightgray);
imagerectangle($im,0,0,299,199,$black);
imagefilledellipse($im,150,100,210,110,$white);
imagefilledellipse($im,150,100,200,100,$darkgreen);
header('Content-type: image/png'); imagepng($im);
Może cos robie nie tak?
Znalazłem rozwiązanie!:) Może mało profesjonalne ale działa.
Dla pierwszego listingu:
....
$graph->Stroke("graph.jpg");
echo ('<img src="graph.jpg?' .time(). '">');
i dla drugiego:
$im=imagecreatetruecolor( 300, 200);
$black=imagecolorallocate($im, 0, 0, 0);
$lightgray=imagecolorallocate($im, 230, 230, 230);
$darkgreen=imagecolorallocate($im, 80, 140, 80);
$white=imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im,0,0,299,199 ,$lightgray);
imagerectangle($im,0,0,299,199,$black);
imagefilledellipse($im,150,100,210,110,$white);
imagefilledellipse($im,150,100,200,100,$darkgreen);
imagepng($im, 'test.png');
echo ('<img src="test.png?' .time(). '">');
Może inne sugestie?