Thursday 2 October 2008

Google Motion Charts in Apex (or Me, February, March & Mummy)

I've got an old Iraqi 100 dinars note in my wallet (don't ask me why - long story) and it's got this huge picture of Saddam Hussein on it. Just how vain do you have to be as a president to put your own face on your country's money? Or what about President Saparmurat Niyazov of Turkmenistan who was so egocentric that he renamed the month of January after himself and April after his mother?

Crazy, huh? Except we've all got a little narcissistic dictator in us, which is why I sometimes obsessively keep an eye on this blog's hit-counter. Which is why I know that most people who chance upon this blog do so from googling "AnyCharts" or "FusionCharts" (see my post about integrating FusionCharts with Apex here). Flash charts are obviously a big thing: users find them informative and we developers find them fun to play with.

Which is why I nearly wet myself with excitement when I heard that Gapminder's really cool flash chart (go on, click the link and press play. We'll wait for you) had recently been rebranded as 'motion charts', released as a Google gadget and can be accessed using the Google visualization API (no, I hadn't heard of it either). How cool would it be to have one of them in your apex app? (The Google visualization gallery actually has quite a few interesting charts; they're probably worth a second look too.)

The Google motion chart page, fortunately, contains some sample code (although you might want to read the Google Visualization overview to fully understand how the whole thing holds together). To use it in your apex application all you have to do is create a Dynamic PL/SQL region and output the javascript code using htp.prn, populating the Google DataTable in a pl/sql loop.

And that's that. Easy-peasy when you know how.

The only small issues I've had with motion charts so far is that while they seem happy to display an annual timeline they do appear a little buggy when you try to portray smaller date increases, and no matter what the user guide says I am unable programmatically control the size or colour of the bubbles.


3 comments:

Anonymous said...

Hi,

I tried to use google sample in a PL/SQL dynamic contend using The "Hello World" of Using Visualizations from google.

But it did not work. I just have a text "Google" on my page.
Do you have any sample with google vizualisation?

Thanks.
Georges

Anonymous said...

Hi,

Finally i succeed to make a test integration with google visualization.
Here is a sample based on table DEMO_ORDER_ITEMS :
http://apex.oracle.com/pls/otn/f?p=37886:1

Thanks for this post.
Georges.

David Njoku said...

You're welcome.