logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Graphs or Images in PHP?
Author
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Fri 29 Sep '06 15:50    Post subject: Graphs or Images in PHP? Reply with quote

Hi all

I'm currently working on a project which requires me to get input data from a source of some sort and display the results of the inputted data(i.e numerical values) based on certain criteria, hopefully, in a graphical form.

I'm planning on doing this web application using php, and I would like to know if the above mentioned is possible?And how can I achieve my goal?

The graphical representation of the input data would be nice in a graph form. Currently these graphs are done in MS Excel based on the data in the excel sheet.

ANY help would be much appreciated.

Thanks. Smile

Quote:
Every man has to go through hell...to reach his paradise
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7360
Location: Germany, Next to Hamburg

PostPosted: Fri 29 Sep '06 16:22    Post subject: Reply with quote

The docu from php.net is very good!

www.php.net/imagestring

img.php
Code:

<?
header ("Content-type: image/png");

$img_handle = ImageCreate (200, 20) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 235, 235, 51);
ImageString ($img_handle, 10, 25, 5,  "Hello world!", $txt_color);
ImagePng ($img_handle);
?>


Code:

<img src="img.php" bla bla bla>
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Tue 03 Oct '06 21:54    Post subject: Reply with quote

You can find numerous open source graph generating scripts, and like my PHP programmers; I am lazy, which is a good thing. Why re-invent the wheel. Instead when possible, legal, and appropriate, simply go to a site such as http://www.hotscripts.com and then review, preview, test and perhaps implement a script that is available.

Very often they are not quite what you want and you must actually write a complete script. Creating a graph, especially a bar graph generating script, is not that difficult, but it is far easier to understand it by studying the work that others have already provided for us via such sites as Hot Scripts (and others like it).

I would likely go with using the GD Library in PHP, while very complicated to say the least, it is fast and stable. Another avenue for creating images is via Image Magick. If you run PHP as a CGI or FCGI, you can reliably generate images with great ease in Image Magick, http://www.imagemagick.org, through command line calls. I recommend against using any command line calls in PHP if you run the SAPI method of script execution; it is simply not stable on Windows at this time.

I use both GD and Image Magick (Im via FCGI and PHP5) and the results are splendid. Best of luck to you.
Back to top
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Tue 03 Oct '06 22:02    Post subject: Reply with quote

Thanks Brian
Back to top


Reply to topic   Topic: Graphs or Images in PHP? View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner