Using PHP/Curl to make big Google Charts

Google charts is a wonderful tool for generating all kinds of graphs and charts. It provides two methods for supplying data, either in the URL or via POST.
The URL version is limited to 2048 characters and the POST version is limited to 16K characters. I wish the FAQ explained a little more about why the limitation exists.

I’ve run into two problems using it in my applications. SSL applications complain if any non-ssl content is pulled into the page and occasionally, I have tables too large for the URL api but that really is the only way to retrieve the image in my application.

I’ve got a simple php-curl based proxy which solves both issues. https://github.com/derak-kilgo/google-chart-proxy Its a drop in replacement for the google’s chart URL.

http://chart.apis.google.com/chart?chs=350x225&cht=p3&chd=s:Mx&chdl=Charts+Users|Should+Use+Charts&chl=Users|Don't+Use&chtt=Google+Charts&chts=676767,20

becomes

http://your-domain.com/proxy.php?chs=350x225&cht=p3&chd=s:Mx&chdl=Charts+Users|Should+Use+Charts&chl=Users|Don't+Use&chtt=Google+Charts&chts=676767,20

Its just that simple.

 

derak

 

Leave a Reply

Your email address will not be published. Required fields are marked *