pureMango.co.uk
there's nothing about mangos or purity. It's just a name..PDF conversion can be simple and fast - with the right software. The best PDF to Excel converter can also convert PDF to doc, making PDF viewing easy. Find great deals on PDF converters online!
check out the things I have found in books!
Creates a simple dynamic PHP bar graph from session data.
Customisable Features:
- Bar Colour
- Bar Height
- Grid Space
- Title
- Footer
source | demo
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/
Who: u24
When: December 15th, 2004
Says: to output a jpg, just change the header line to
header("Content-type: image/jpeg");
and the penultimate line to
ImageJPG($pic);
Who:
When: January 14th, 2005
Says: Can the header contain a type for pdf files? Help.
Who: u24
When: January 15th, 2005
Says: the way PHP creates PDFs is very different to image creation. If you want to create a pdf of the graph, I'd suggest outputing the image to a file (see the ImagePNG / ImageJPG function reference on php.net) and then using a third party jpg/png to pdf conversion utility.
I might add this functionality at a later date.
Who: u24
When: January 15th, 2005
Says: FYI, the header line to use for PDFs would be:
Content-type: application/pdf
but simply changing this in the script above wouldn't work. (either the browser would display the JPG, as a JPG, or nothing would be displayed at all)
Who: David
When: February 5th, 2005
Says: I can't find any install and operation instructions.
Am I missing something here?
Who: u24
When: February 6th, 2005
Says: well... you'll need a webserver that runs PHP. copy the source code to a file on that webserver, follow the usage info in the source code... and that's it, really.
If you're having error messages come up, post details here and I'll try to help.
Who: http://www.blog-buster.net
When: February 19th, 2005
Says: Complimenti da noi blogger http://www.blog-buster.net
Who:
When: February 25th, 2005
Says: Why is the source code for the demo page encrypted... and how do you admin the session info?
Who: u24
When: February 25th, 2005
Says: it's not encrypted... you can't view source on the demo because it's an image - no source to view.
see the usage info at the top of the source code for details of how to implement the graph.
I will post more a detailed example at some point in the next few weeks.
Who: mongmonagomango
When: March 18th, 2005
Says: nice script but it doesnt scale very well when dealing with very large numbers, see here for an example
http://www.genietexter.co.uk/test/newgraph.php
---
from u24:
yeah, it's far from perfect - with that particular case, though, you could set grid_space to a higher value (eg 500)
Who: mega-squall
When: April 30th, 2005
Says: I added horizontal scaling, as well as logarithmic scaling. I thought it might be of use for someone else than me ...
I might also add auto-selection for scaling type and passing setup parameters though $_SESSION (or any other variable) in the future.
Example & source code :
http://www.beng.free.fr/phpgraph/
Who: u24
When: May 1st, 2005
Says: very cool addition :-)
Who:
When: June 19th, 2005
Says: my English not strong.
thank you for your software..
Who:
When: August 14th, 2005
Says: can this be vertical instead?
---
from u24:
not at the moment, but I'll try to update this at some point.
In the meantime, investigate the imageRotate function
Who:
When: August 31st, 2005
Says: Hi, Nice script I 'll try to customize it, and came back to post it
Who:
When: September 9th, 2005
Says: Interesting post, i like your blog very much
Who:
When: September 16th, 2005
Says: Hey, very interested in using this script, but I can't figure out how to set it up. What database is it using for the stats? etc., it's giving me an error when I copy the source and run it:
http://www.13scripts.com/tests/graph.php
---
from u24:
it doesn't use any kind of database; you need to set up the amounts array within the graph script itself, or via the session.
Who: Michael
When: September 19th, 2005
Says: Hey..
wonderful and easy to use script but is there any way for it to use negative numbers?
---
from u24:
hmm.. no there isn't.. I'm not sure how you'd go about adding in support for negative numbers. If/when I do a new version I'll add this in, but for the moment hack the code around and see what happens!
Who:
When: September 22nd, 2005
Says: I have this problem when install it, I mean copy the source code then put it into my htdocs dir.
Warning: asort() expects parameter 1 to be array, null given in C:Program FilesApache GroupApache2htdocstempbargraph.php on line 99
Warning: Wrong parameter count for max() in C:Program FilesApache GroupApache2htdocstempbargraph.php on line 102
Fatal error: Call to undefined function ImageCreate() in C:Program FilesApache GroupApache2htdocstempbargraph.php on line 106
Please help. Thanks. M Sopian H
Who:
When: September 22nd, 2005
Says: OK, then, I tried to create new file name start.php with this code :
But, I got a broken image output.
Thanks,
Regards,
M Sopian H
---
from u24:
that code works for me; try downloading graph.php again.
Who:
When: October 10th, 2005
Says: I added an automatic title/footer wrapping if they are too long for the image; image width adjustment based on the length of the bar titles; user defined fonts for the header, footer, and bar titles; optional sorting by the bar title instead of just by bar value, as well as a no sorting option; and optional hexadecimal coloring of the bars; Let me know.
Who:
When: October 10th, 2005
Says: I forgot to post the links. The source is at http://www.freemysqlhost.com/dynamicimgs/graph.php.txt
an example is at
http://www.freemysqlhost.com/dynamicimgs/examplegraph.php
Who: u24
When: October 13th, 2005
Says: nice one, I'd been meaning to do something like that for a while.
I will consolidate all the mods people have made into a new version (bar, pie, scale, vertical, title wrap) at some point fairly soon. (if anyone wants (me) to add some more features, now would be the time to tell me.
Who: u24
When: October 13th, 2005
Says: very nice, in fact. I would have just made the image bigger, but your solution is much more elegant.
Who:
When: October 13th, 2005
Says: Thanks, I appreciate that. I eagerly await V2!
---
from u24:
don't hold your breath, I've got quite a lot of work to do...
Who:
When: November 4th, 2005
Says: Great code. I added a foreach loop at the begining to auto populate the $_session array. Thanks!
Who:
When: January 3rd, 2006
Says: Incredible job on this! I love I love I love this site!
I have address to your site from my friend.
My friends enjoy it as much as I do. Congrats!
That must have been hard to make.
Who:
When: January 4th, 2006
Says: Site was very interesting for me
I wish you and your site everything best!
Who:
When: January 7th, 2006
Says: I enjoyed the time i spent on your
website, thank you very much for that.
Who:
When: January 23rd, 2006
Says: This script did not work when I tried it. It generated some strange characters! Please help!
---
from u24:
ensure you've got the header line:
header("Content-Type: image/png");
If you do have this, try changing the image type to gif or jpg.
Who: ian
When: March 20th, 2006
Says: TO USE MULTIPLE IMAGES ON ONE PAGE
change line #96 from
$amounts = $_SESSION['amounts'];
to
$amounts = $_SESSION[$_GET['arr']]
In a separate file, load the session variable with several arrays
$_SESSION["a1"] = Array("title1: "=>100,"title2: "=>200);
$_SESSION["a2"] = Array("title1: "=>200,"title2: "=>400);
Call the image several times throughout the script using img src of:
graph.php?arr=a1
graph.php?arr=a2
etc.
---
from u24:
nice one - thanks :-)
Who:
When: April 4th, 2006
Says: I figured out this info might be of help. For all users, remember PHPGraph requires GD. This means you require :
1) libgd.so installed on the server
2) php ./configure --with-gd
3) LoadModule libgd.so in php.ini
If any of those misses, you'll get a broken image output. If you remove the `header()`instruction, the script will output a text/html with a content being something like :
fatal error : unknown function
More info avaliable on http://php.net/gd ... Cheers !
Who:
When: June 7th, 2006
Says: This isn't scalabe, so when you're dealing with very large numbers doesn't work well - the image goes off the screen.
Is there any way of restricting the image width whilst maintaining proportion?
---
from u24:
you could try resizing the image once it's created; try searching for a thumbnailing script
Who: uh, me
When: June 8th, 2006
Says: how would you go about writing the php code for retrieving the numbers from mysql database?
Who:
When: July 24th, 2006
Says: This site is very useful. Keep up this excellent work - very good.
Who: mega-squall
When: July 25th, 2006
Says: You can try my version to have the resize function. Instead of the intervall my script asks for the width of the image ...
For the database feature, consider using PDO, especially the PDOStatement->fetchAll() method ... This is better because : (1) PDO makes cleaner code and makes you a better coder (2) PDO allows you to easily port your application to other DBMS such as Oracle, Postgré, Access, et caetera ... (3) PDO is compatible with MySQL 4.x features (and MySQL 5.x are on the way) (4) PDO will be the only way to connect to a database in PHP6 !
Such scipt would more or less look like this :
Then the $data array can be used to populate your image.
NOTA: my script has moved. I'm planning to work on a little portal to regroup all my sources but got a little time to go ... I added a 301 redirect at the old URL, but the new one is now :
http://ledry.free.fr/phpgraph/
Who: mega-squall
When: July 25th, 2006
Says: Sorry the code hasn't displayed properly because of the php tags i added. Code was :
$db = new PDO ("mysql:host=localhost;dbname=mydb");
$data = $db->query ("SELECT * FOM `mytable`");
$data = $data->fetchAll();
---
from u24:
thanks for posting this, I appreciate it :)
Who: amit
When: August 10th, 2006
Says: hi...i cant see any graph after running the code....i m using php 4.2 ...and running the code windows explorer
Who: Amy Kimber
When: August 16th, 2006
Says: ooo, I like this! I plugged it into any array of data I had and bamb! there was my graph - love it!
Will play more with this one I think.
Amy
Who:
When: September 14th, 2006
Says: Very useful, your script. In my tests, I\'ve found more interesting make the graph routine like a function, so I can save a image and load with more variables.
---
from u24:
yeah good idea
Who:
When: November 11th, 2006
Says: For multiple images graphes on a page
in code replace line 86 and 87
// get amounts and titles from session.
$amounts = unserialize(urldecode($_GET["data"]));
in your page
$tab= Array();
fill your $tab with data then call:
echo '';
Who:
When: May 20th, 2007
Says: hi & thnx
but how to use unicode characters ?
help me ...
---
from u24:
I have no idea. My suggestion would be to convert to ascii before sending it to the graph.
Who:
When: February 28th, 2008
Says: Great script! It misses some features I added, like:
- a multiplier for the values
- a maximumwidth including scaling
- all parameters to be changed via GET
- using multiple datasets by not using a default 'amounts' name but 1 via GET
I can make great overview graph pages with this. Email me if you wanna have it!
Who: samn
When: March 31st, 2008
Says: well i tried the script but it doesn't show any output, rather it shows a small cross instead of an image...........wa shud i do!!!
upon running the graph.php page alone it gives the following error:
Cannot send session cache limiter - headers already sent (output started at /usr/local/apache2/htdocs/sms_reports/barchart.php:12)
and this one 2:
Call to undefined function: imagecreate() in /usr/local/apache2/htdocs/sms_reports/barchart.php
Who: samn
When: March 31st, 2008
Says: well i tried the script but it doesnt show any output, rather it shows a small cross instead of an image...........wa shud i do!!!
Who: samn
When: March 31st, 2008
Says: Do i need to install a GD Module for it.......n if it already exists how do we get to know whether it exists
Who:
When: April 16th, 2008
Says: Thanks Dude it is very much usefual and eay to implement too. gr8 work keep it up.
Who:
When: April 17th, 2008
Says: i tried the script but it doesnt work, it shows an error
The image http://localhost/sample/index.php cannot be displayed, because it contains errors.
need help asap..tnx..
Who: xy
When: April 18th, 2008
Says: nice script.. but it looks good if it has labels on amounts..anyone who could contribute will greatly appreciate..:)
Who:
When: June 18th, 2008
Says: anyone know how to call a .php file as a png?
i have this file i'm working on, but i would rather call it as a jpg, or png, instead of
calling as a img src=filename.php
---
from u24:
look into apache's forceType directive
Who:
When: August 7th, 2008
Says: Ive tried to embbed into a php file this script and i got the message:
\" headers already sent by (output started at C:\\AppServ\\www\\...)\"
It works fine on a blank file, but i cant embbed it on a existing file
---
from u24:
link to it in an img tag from html?
Who:
When: August 25th, 2008
Says: the function SetFillColor() has been added..
but error still happen..
Fatal error: Call to a member function SetFillColor() on a non-object in grap.phtml on line 27
* denotes a required field.
Your email address will be converted to an image to prevent spambots picking it up.









