PHP Bar Graph / Bar Chart


This script allows you to create a simple dynamic horizontal PHP bar graph / bar chart from session data. With labels, colours, and many other customisable features. Great if you just want a simple PHP chart with no fuss.

Customisable Features:

  • Bar Colour
  • Bar Height
  • Grid Space
  • Title
  • Footer

The demo randomly customises itself, so refresh this page a few times to see what it can do.

Download PHP Source

DEMO:
PHP Bar Chart

If you use or modify the graph, please either email me about any modifications you make, or post a comment here with feedback about usability – bugs, feature requests etc, cheers :-)

Mega-Squall has modified the code to include two types of scaling; check it out @ http://ledry.free.fr/phpgraph/ – thanks!
(local copy here)


Related Posts:

, , ,

  1. #1 by Sean on May 5, 2009 - 6:32 pm

    Your script has one major downside that makes it pretty much unusable for most applications…. Have you tried to show maybe a figure of 25,000 for one of your bars and see how big the image gets?? Not sure a 2500pixel wide image is going to be ideal for a web page 1024 pixels wide huh ;) Otherwise good starting concept..

    • #2 by user24 on May 6, 2009 - 4:15 am

      I believe Mega-Squall’s improved code deals with exactly that situation by allowing scaling of the graph ;)

  2. #3 by Bobby on December 14, 2009 - 12:27 pm

    I’m sorry, but scaling example simply doesn’t work!

    Test it, man!

  3. #4 by qwaszx on February 11, 2010 - 2:18 am

    Hi,

    Your graph is fantastic. I made some changes such as the size of the image, I deleted random color generator and random size.
    I am taking data from my sql db and it works.

    Thanks

    • #5 by rohi on January 28, 2011 - 1:16 am

      can u just let me know how to get the sql data to array?

  4. #6 by peer imran ali on February 21, 2010 - 11:11 am

    Thanx
    Nice article.

  5. #7 by seyi on August 12, 2010 - 10:24 am

    @qwaszx ……….pls aw did u get ur data from mysql db…..mine dosent seem to work

  6. #8 by Jorge on November 19, 2010 - 3:44 am

    Very good work. With some little changes I’m doing a very good presentation conecting to my FileMaker / ODBC presentation.

  7. #9 by Browserspiele on January 7, 2011 - 2:04 pm

    Great article, thank you. Keep up the good work.

  8. #10 by Analia-san on January 19, 2011 - 6:34 am

    Nice script! Very simple and clean. Exactly what I was looking for. Thank you!!

  9. #11 by tribonia on January 26, 2011 - 2:37 am

    Thank for the information. Seems to be very simple, the graph is fantastic. Greets

  10. #12 by Alen on March 11, 2011 - 1:52 pm

    I was looking at this but simply I could not update this chart source to display only one bar with final amount like donation.
    Donated amount 12€ and goal amount 40€
    please can somebody advice me about that as well I would like to not have random color, and numbers only entered

    Thank you
    Alen

  11. #13 by Don on October 14, 2011 - 3:38 pm

    Hello, trying out your code but cant seem to load the graph if i do not use the demo (randomly generated stuff)
    I have a text file that i load into an array, i want the array data to generate the points on the graph.
    when i am done it only shows one graph bar and it changes if i refresh my page to the next data-point in the file.

    what am i doing wrong?

  12. #14 by shweta on January 4, 2012 - 12:08 pm

    Hello,
    your graph is really nice.but its not working on my website.i designed a website http://www.irse.in and i want to show the poll result through this graph.It creates an image of the graph but did’nt show in right format.Its decodes the image.

Comments are closed.