The problem is that you are mixing HTML / text output with image output.
Each time you create graphical content for a PHP script, you must process the output differently than regular HTML or text.
There are several routes, I will briefly talk about them here.
Save the output to a file and use this file name in your HTML
//replace this line: // Display the graph //$graph->Stroke(); // with these lines: // Default is PNG so use ".png" as suffix $fileName = "/tmp/imagefile.png"; $graph->img->Stream($fileName);
.. then use $filename in the image tag, for example (for example):
print '<img src="'.$filename.'" />';
Create a standalone PHP script that will display the graphics
You can use the sample script as is, only in a file called graph_render_script.php . Then in your HTML you use this script as a source:
<img src="graph_render_script.php" />
Source data with database-64
Another way is to use base-64 encoded image data. It is relatively simple:
print '<img src="data:image/png;base64,'.base64_encode($graph->Stroke()).'" />';
As always, the documentation should be your guide!
Documentation
source share