I'm coming up to speed on the new Google Visualization APIs this week like a lot of other people. As I'm working through my new application that uses this API and Google Docs spreadsheets, I'm running into some issues that aren't covered in the online documentation for the API. I'll post those issues along with their resolution here, so if you run into problems, this is a good place to look. If you run into problems that aren't covered, please add them to the comments section. Of course, the first place to look if you run into issues is on the Google Visualization API Group.
Column labels don't work like you might think they should
Throughout the Query Language Reference the examples use the labels from the following table:
name | dept | lunchTime | salary | hireDate | age | isSenior | seniorityStartTime |
John | Eng | 12:00:00 | 1000 | 2005-03-19 | 35 | true | 2007-12-02 15:56:00 |
Dave | Eng | 12:00:00 | 500 | 2006-04-19 | 27 | false | null |
Sally | Eng | 13:00:00 | 600 | 2005-10-10 | 30 | false | null |
Ben | Sales | 12:00:00 | 400 | 2002-10-10 | 32 | true | 2005-03-09 12:30:00 |
Dana | Sales | 12:00:00 | 350 | 2004-09-08 | 25 | false | null |
Mike | Marketing | 13:00:00 | 800 | 2005-01-10 | 24 | true | 2007-12-30 14:40:00 |
Examples are then presented like:
|
|
You can't query for a whole column ala B:B
The API will return an 'access denied' error message.
B | C | D | E |
=unique(B:B) | =rows(unique(B:B)) |
Update! Thanks VizGuy!
You can query an entire column at once, just not using B:B. First remove the range specification from the data source URL so it reads like:
Then, query the entire column using a statement like:
query.setQuery("select B where B != ''");
You can use the same query string for different spreadsheet ranges
The documentation of the 'Hello World' application says to get a query string like this:
- Open a spreadsheet.
- Insert a gadget, select the range of cell you want to read.
- In the gadget title, click the arrow icon on top right.
- select 'get query data-source URL' from the popup menu.
The data source URL for a Google Spreadsheet will look something like
http://spreadsheets.google.com?...&key=123ABC
The part of the query string that's been hidden by the ellipses above looks like:
google.com/tq?range=B1:B10&key=pvFX...
Blogger.com Specific: You can run scripts in a post, it just takes some finesse
Finally:
Be Warned:
This setting will retro-actively be the same for all your other posts. That means that there may be subtle, and not-so-subtle formatting differences in your published posts while this setting is changed. The good news is that these changes revert back to normal when you revert the setting.
Also, always keep a record of your scripts on your own machine. I've seen scripts get munged with br tags by blogger.com anyway.
The Permanent Fix:
When your script is ready to go, remove all line-feeds, and paste it into the post as a single long line.
Gotcha Number 5 is so convoluted it got its own page.
Comments
Post a Comment
Please leave your comments on this topic: