Figuring out the Google Visualization API
During this week, I've been getting up to speed on the
Google Visualization API:
-
The Google Visualization API lets you access multiple sources of structured data that you can display, choosing from a large selection of visualizations. The Google Visualization API also provides a platform that can be used to create, share and reuse visualizations written by the developer community at large.
The first part of my study was to work through
Developers Guide - Google Visualization API. You need to copy and paste and substitute a DATA_SOURCE_URL, which you can get from a spreadsheet by inserting a gadget (which in turns gets you a URL.) My implementation of the tutorial is http://mashupguide.net/PW/2008/03/gvisualization/helloworld.html. The spreadsheet that is the data source is http://spreadsheets.google.com/pub?key=pYxyro01gAliwKMr__j9uEw -- and the corresponding DATA_SOURCE_URL is http://spreadsheets.google.com/tq?key=pYxyro01gAliwKMr__j9uEw&gid=0.
It's useful to compare the variant URLs for data sources:
-
http://spreadsheets.google.com/tq?key=pYxyro01gAliwKMr__j9uEw&gid=0 (entire sheet)
-
http://spreadsheets.google.com/tq?key=pYxyro01gAliwKMr__j9uEw&range=A2:B7&gid=0 (selected range)
-
http://spreadsheets.google.com/tq?range=A2:B6&key=pYxyro01gAliwKMr__j9uEw&gid=0 (corresponding to a gadget)
Although the documentation mentions that "The Google Visualization API lets you access multiple sources", note the answer to
What data sources can I access using the Visualization API?:
-
With the Visualization API you can access any data source that supports the API. In order to allow developers to start using the API immediately, we have released the API with support on Google Spreadsheets. We plan to add more data sources in the near future.
I'll be on the lookout for some official documentation for the data source API so that I can use or implement a data source other than Google Spreadsheet.
Query Language Reference (Version 0.6) - Google Visualization API - Google Code documents part of the data source API -- the query language that you will have to implement.
Embedding the Visualization Gadget in a GSheet
Google Visualization API Gadget Gallery - Google Visualization API - Google Code is a showcase for what people have done with these gadgets so far.
If you take a look at
my test spreadsheet, you'll see a bunch of embedded visualization gadgets.
How to get started with visualization gadgets? Read
Using Visualization Gadgets - Google Visualization API to learn how to embed a visualization gadget into a GSheet, specifically the sample gadget specified by http://www.google.com/ig/modules/simple-table.xml
Embedding a visualization gadget in a web page
Relationship to Google Gadgets
Google Visualization Gadgets are related to related to
Google Gadgets though I'm not totally clear on the relationship between the two. It seems that one can embed any visualization gadgets into iGoogle, but can you embed any regular Google gadget into a GSheet? I'm not sure what the answer is right now.
Google Gadget to display ProgrammableWeb stats
I wrote a Google Gadget to display the number of current APIs listed on ProgrammableWeb: http://mashupguide.net/PW/2008/03/ggadgets/ProgrammableWeb.xml To use it you need to get an API key for PW by following instructions at
ProgrammableWeb API: Overview.
My quest: to embed this gadget into a GSheet. The problem is that when I try to insert the gadget into a GSheet, I get an error:
-
Sorry! Gadget cannot be displayed until all required settings are provided.
Why does this gadget work in the context of iGoogle but not in GSheet? I think that I've nailed down a specific bug in how a visualization gadget interacts with Gsheet. http://mashupguide.net/PW/2008/03/gvisualization/dynamichelloworld.xml works but http://mashupguide.net/PW/2008/03/gvisualization/dynamichelloworld_a.xml gives rise to the above error message. (Both work in the iGoogle context.) The second gadget includes an extra
<UserPref name="PW_API_KEY"
display_name="API key for ProgrammableWeb"
datatype="string"
required="true">
</UserPref>
I wouldn't think that simply defining an extra UserPref should cause this error message -- and hence, there is a bug.
Misc. Points
-
authorization is done via browser credentials? When you create a spreadsheet, it's assigned a key -- and depending on whether the spreadsheet is published, you can see it (or not) if you are properly logged in.
-
Using JSON with Google Data APIs - Google Data APIs might be useful
-
Google Gadgets Editor is a useful tool.
Outstanding Questions
-
Does the Visualization API have write-capability?
-
Does it make sense to make use of the Visualization API something like Excel macros?
