Google Charts API and FileMaker
I’ve been spending most of my time over the past week or so working on integrating the Google Charts API into my upcoming FileMaker Pro CRM solution. For those not familiar with it the Google Charts API was released on December 6, 2007 and lets you dynamically generate charts via an HTTP request. So what’s in it for FileMaker developers? Well with the introduction of the Web Viewer in FileMaker Pro 8.5 you can now compose a chart request in your database and have it displayed on a Web Viewer on a layout. As the data changes the chart updates live. The chart is returned as a .PNG file. Here’s an example:
http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250×100&chl=Hello|World
You obviously require an active Internet connection to use this feature. Learning the API is pretty straightforward and most of the time will be spent getting familiar with the different charts available and the syntax required in the HTTP request, along with which data encoding method you will decide to use.
As I did more testing I was disapointed that, as the chart is a PNG file, I wasn’t able to use the new layout object resizing to resize the chart to expand/contract as the web viewer was resized, which is how I normally setup my web viewer layouts. So I decided to use the Troi URL plugin which is able to GET images from a website. As the URL appears in this format:
http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250×100&chl=Hello|World
you are not able to use that as is to retrieve the PNG file into a FileMaker container field. However there is a new switch in v2.0 and later of the plugin -“-ExtraImageCheck” – which when used with the TURL_Get function checks the returned data to verify if it is an image, even though there is no .png extension on the URL. Now I can set the container field to resize with the layout and the chart grows bigger and smaller – you don’t have control over the resolution of the PNG so it’s appearance will start to degrade as you increase it’s size (you do have control over the image size in pixels).
I’ve been quite impressed with the features of the Google Charts API. It was updated on March 20, 2008 with some new chart types (the maps one is pretty cool) and lifted the previous limit of 50,000 queries per user per day. FMWebschool have a sample (locked) file that you can download here that shows some of the options for FileMaker integration, along with 2 movies here and here. If you know what data you are charting and what chart types you prefer you should be able to integrate Google Charts pretty quickly into your FileMaker Pro solution. Whilst not offering as many features as some of the charting plugins available you can’t complain about the price.
A great future enhancement of the Web Viewer in FileMaker Pro would be the addition of another option for “Google Charts” to make setting up a web viewer to display Google Charts even easier.
Andrew Duncan