Monday, 26 August 2013

How the google charts query language works?

How the google charts query language works?

I have implemented my own datasource in Go, which returns a JSON string.
The data source is working fine and returning the correct JSON format
expected by the chart (which is actually a table object to make the tests
easier).
Now, I'd like to be able to use the query language features for my chart
and something I could not figure out is how exactly the query language
works. Let's take the table below as example:
Name | Age | Phone
-------------------------------
John | 23 | 12341234
Chris | 47 | 54223452
Sam | 36 | 69694356
When called, my datasource will return a JSON representation of the entire
table above. In theory, I should be able to do something like this from my
Javascript
query.setQuery('select Name, Age');
So, the result would ignore the column "Phone".
Now, my question is:
Is the setQuery() method applied to the JSON response only, or my
datasource should be able to handle the query on request and return the
correct data (only Name and Age columns). I'm not sure if the query
language will act on the JSON response or if it's just an interface to
tell the server what to do and the server should be able to prepare the
correct data.
I'm asking that because as I said, my JSON response works fine, however
the setQuery() method is being ignored. My table always shows the entire
Dataset, no matter what I put on the setQuery method. Even if I define a
column which does not exist, it does not cause any error. I did some tests
using a google spreadsheet and it works just fine. I should add that the
structure of the JSON response from my app and the one from the google
spreadsheet looks exactly the same. Any help would be very much
appreciated.
Thanks,
JB

No comments:

Post a Comment