There could be many different ways. Basically, you can generate any graphics out of your data on the server side, save it in a temporary file, or provide graphics content on the fly prescribing proper
media type in your HTTP response. With PHP, it can be anything. It could be something like "image/png", "image/jpeg", etc. Please see:
http://en.wikipedia.org/wiki/Media_type[
^],
http://www.php.net/manual/en/function.header.php[
^],
the ultimate document on available MIME types is this one (for images):
http://www.iana.org/assignments/media-types/media-types.xhtml#image[
^].
So, in your PHP script, it could be something like
header('Content-type: image/png');
header('Content-type: image/jpeg');
For generation of general graphics, there are many libraries (like ImageMagick,
http://www.php.net/manual/en/book.imagick.php[
^]).
This is how it works. In practice, you can find some read-to-use open-source charting library:
http://bit.ly/OCsZbx[
^].
There is a very attractive
alternative approach: using HTML5 Canvas feature:
http://en.wikipedia.org/wiki/HTML5_Canvas[
^].
For example, this product:
http://canvasjs.com[
^].
You can find more:
http://bit.ly/OCww9S[
^].
If you use this approach, your PHP code should be used to generate data and Javascript needed to present graphics. The attractiveness of this approach is that you can make graphics (especially changing view options, limits, etc.) on the fly with great performance, because all such processing can be done purely on client side.
—SA