Tigran's blog Blog about Hi-Tech

15Jul/090

Tutorial: Simple Bar Chart using PHP

In this small tutorial I will explain how I created simple bar chart using PHP. Maybe in future I will write more about charts and to expand this library. Tutorial is for beginners.  For image manipulation and processing we will use GD library which is by default come's with PHP distributions. You need to enable GD2 extension in PHP.ini. Search for ";extension=php_gd2.dll" and remove ; character.

The code below calculate the heights for each value to be shown in chart, draws that bars and returns image data as variable.

Click here to view bar.php code