Hey all, I'm having a little issue that I could use a mind jogger with. I am trying to add some dynamic charts to a site I am working on. All the data is already generated in various classes and all I need to do is add the charts. Looking at various scripts (http://www.ebrueggeman.com/phpgraphlib/examples.php) it seems that they all call a php script from within an IMG tag.. <?php include("phpgraphlib.php"); $graph=new PHPGraphLib(500,350); $data=array(12124,5535,43373,22223,90432,23332,15544,24523,32778,38878,28787,33243,34832,32302); $graph->addData($data); $graph->setTitle("Widgets Produced"); $graph->setGradient("red", "maroon"); $graph->createGraph(); ?> PHP: The above would be its own file and then called by something like: <html> <img src="graph_bar.php" /> </html> HTML: What I can not figure out for the life of me is how I could get the data I actually want to display from my main program to this side chart. The only options I can think of are: 1. Write it to a databae and then call it from the chart php script. Not efficient at all. 2. Write all the data to cookies lol 3. Create my own charting script - lots of work! Any ideas?
Without seeing more of the data I really have no idea what you're using. Not sure if maybe it's just missing the header() call to make it look like a jpeg or if that's a part of the script, and if you have all the data right. Go to just graph_bar.php and look and see if it's displaying or if it's giving you errors. Also, a friend of mine told me the other day that the Google Graph API (maybe it's the Chart API) is pretty simple and makes excellent graphs, you could consider that.
Depending on exactly how much data you are trying to push into the image, you could also just pass it along as GET parameters to the graph_bar.php script. eg. <img src="graph_bar.php?a=1234&b=5678&c=9012" /> or something similar. Another alternative is to set the data into a session variable.