Jump to content

[SOLVED] Embedding Graphs in Web Page


barneyf

Recommended Posts

I have an intranet application where I want to embed database driven XY graphs in a web page.  I have a PHP script ("master.php") that generates the HTML output consisting of a mixture of HTML tables and graphs.  Currently master.php writes out an IMG tag that uses graph.php as the data source.

 

graph.php generates the PNG image via the GD library.  This XY graph will have 1000 points per line and could have 20 or 30 lines so lots of data.  This works OK if graph.php pulls the data from the database.

 

But... I don't want to have graph pull the database info, I want master.php to pull the data, massage it, and pass it on to graph.php as a 2D array.  This keeps all of my database queries & data massaging in master.php.  All graph.php should do is take the array and generate a PNG image for the graph.

 

I am looking for suggestions on how master.php can pass the data on to graph.php and prefer not to use GET (too much data) or a file (too slow).  Using SESSION would work, but seems like overkill as I don't need to keep the data once it is passed on to graph.php.  Any elegant solutions to this situation?  If I could make graph.php an object and have the IMG tag call one of it's methods, that would be elegant.  But so far I haven't found a way to make that work.

Link to comment
Share on other sites

After much research, I determined that the only way to display the image is with the HTML <img src="...."> tag.  This can either call a separate PHP script, or you can embed  a small image (ie icon sized) as a URL embedded image.  So I use the $_SESSION global to hold the data while waiting for the user's browser to call the PHP page defined in the <img src="....." > tag.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.