views:

9

answers:

1

I'm using the succinctly named googlechartseasyphpclass script to generate google charts from numbers I'm grabbing from a database. After the charts are generated, I want to put the results in a different table. The way you generate a Google Charts URL using the easyphpclass script is like this:

$chart=new googleChart(null,'line',$title,'500x200');
$chart->loadData($chartData);
$chart->setLabels($axislabel);
$chart->draw(); 

That last line is tripping me up. I can't shove the URL it produces into a variable so I can put it in a database table. It just draws the chart on the screen. Is there a good way of taking that value and making it something I can use? Thanks!

+1  A: 

From the documentation you linked, it'll echo a <img> tag if the first parameter is true (which it is by default) and will return a url if the first parameter is false. Thus you could do something like:

$chart_url = $chart->draw(false);

Or capture the entire <img> tag:

$chart_img_tag = '<img src="' . $chart->draw(false) . '" />';

You could use output buffering but for something like this it's really unnecessary overkill because it's trivial to output your own <img> tag.

Daniel Vandersluis
Great, that worked! Thanks so much!
Dave