google.visualization.Query issue

164 views
Skip to first unread message

Ramana

unread,
Jul 22, 2011, 4:45:52 PM7/22/11
to Google Visualization API
Hello All,

I am using the google.visualization.Query method to retrieve the data
from my Fusion Table. The Fusion Table contains nearly 12000+ rows of
data. But when i try to retrieve the rows in the callback method of
send(getData), response.getDataTable().getNumberOfRows() only returns
500 rows. Any idea why it is not returning all the rows at once?

Note: response is the parameter to the getData method.

I was wondering if there is any limitation to the noof rows returned?

Regards,
Ramana

visigoth

unread,
Jul 24, 2011, 3:33:43 AM7/24/11
to google-visua...@googlegroups.com
Hi Ramana,

Could you please post this in the Fusion Table Users Group so we can check whether this limitation is imposed by Fusion Tables?
I don't know of any such limitation as part of the GViz DataTable.

Riccardo Govoni ☢

unread,
Jul 26, 2011, 12:38:46 PM7/26/11
to google-visua...@googlegroups.com
Note that there is indeed a limitation in the number of rows that you can get from a Fusion Table via the Google Chart Tools API and that is set to 500 rows. See http://code.google.com/apis/fusiontables/docs/sample_code.html :

"Using the Google Chart Tools, you can request data from Fusion Tables to use in visualizations or to display directly in an HTML page. Note: responses are limited to 500 rows of data"

I don't know the reason for such limitation, but you can work around it by using the raw fusion tables SQL API (http://code.google.com/apis/fusiontables/docs/developers_guide.html ) and query your datasource asking for a response in JSONP format. This doesn't seem to have the same row limitation. Once you have the response in JSONP format, you can easily transform it into a DataTable on the client and then pass it to the visualization.

You can use this file, starting from line 105 as an example of the process (using the jQuery library).

/R.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/ZLq586CqOQQJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Ramana

unread,
Jul 26, 2011, 3:26:36 PM7/26/11
to Google Visualization API
Hi Riccardo,
I was also using jquery to use the raw fusion table api. And when i
looked at your code and tried the same thing, i noticed two things:
1) when i have dataType:'json' , it does not work
2) when i use jsonp instead, dataType : 'jsonp' , it is fetching data
but in Firebug i see an error message 'script too large'. Not sure
what's going on.

Here is the code snippet i am using.

function queryFusionTable()
{
$.ajax(
{
url: 'https://www.google.com/fusiontables/api/query?sql='
+
encodeURIComponent('SELECT geometry FROM
1182169'),
dataType:'jsonp',
jsonp :
'jsonCallback',
success : function(json)
{
var rows = json.table.rows;
var cols = json.table.cols;
........
.........
}
}
);
}

Do you know what could be wrong here?

On Jul 26, 12:38 pm, Riccardo Govoni ☢ <battleho...@gmail.com> wrote:
> Note that there is indeed a limitation in the number of rows that you can
> get from a Fusion Table via the Google Chart Tools API and that is set to
> 500 rows. Seehttp://code.google.com/apis/fusiontables/docs/sample_code.html
>  :
>
> "Using the Google Chart
> Tools<http://code.google.com/apis/charttools/index.html>,
> you can request data from Fusion Tables to use in visualizations or to
> display directly in an HTML page. Note: responses are limited to 500 rows of
> data"
>
> I don't know the reason for such limitation, but you can work around it by
> using the raw fusion tables SQL API (http://code.google.com/apis/fusiontables/docs/developers_guide.html) and
> query your datasource asking for a response in JSONP format. This doesn't
> seem to have the same row limitation. Once you have the response in JSONP
> format, you can easily transform it into a DataTable on the client and then
> pass it to the visualization.
>
> You can use this
> file<http://code.google.com/p/google-visualization-io2011/source/browse/js...>,
> starting from line 105 as an example of the process (using the jQuery
> library).
>
> /R.
>
> On 24 July 2011 08:33, visigoth <visig...@google.com> wrote:
>
>
>
>
>
>
>
> > Hi Ramana,
>
> > Could you please post this in the Fusion Table Users Group<https://groups.google.com/forum/#!forum/fusion-tables-users-group> so

Riccardo Govoni ☢

unread,
Jul 26, 2011, 6:11:27 PM7/26/11
to google-visua...@googlegroups.com
Your fusion table contains kml data, which makes it very large to download.
Just downloading it as a simple csv (via this url https://www.google.com/fusiontables/api/query?sql=SELECT%20geometry%20FROM%201182169 ) results in a 50Mb file. Formatted in JSON format is likely to be even bigger.

This is probably over the maximum size that Firefox accepts (I'm not sure whether the limitation is in firefox, firebug or the xmlhttprequest that you are firing) and anyway past the size that the browser can easily manage (just the download times are significant, and the browser javascript engine will likely fail / take forever when converting such a payload into a google.visualization.DataTable and displaying it.

I think you should refactor your table and/or the data you fetch to limit the amount of data on the wire. Do you actually need all those kml data on the client ?

/R.

mwcog

unread,
Aug 10, 2011, 9:06:36 AM8/10/11
to Google Visualization API
I'm in the process of trying to implement this code, but (as i'm a
beginner) its going slow. Do you have a working page using this code
I might visit?

Thanks,

A

On Jul 26, 6:11 pm, Riccardo Govoni ☢ <battleho...@gmail.com> wrote:
> Your fusion table contains kml data, which makes it very large to download.
> Just downloading it as a simple csv (via this urlhttps://www.google.com/fusiontables/api/query?sql=SELECT%20geometry%2...)
> results in a 50Mb file. Formatted in JSON format is likely to be even
> bigger.
>
> This is probably over the maximum size that Firefox accepts (I'm not sure
> whether the limitation is in firefox, firebug or the xmlhttprequest that you
> are firing) and anyway past the size that the browser can easily manage
> (just the download times are significant, and the browser javascript engine
> will likely fail / take forever when converting such a payload into a
> google.visualization.DataTable and displaying it.
>
> I think you should refactor your table and/or the data you fetch to limit
> the amount of data on the wire. Do you actually need all those kml data on
> the client ?
>
> /R.
>

Riccardo Govoni ☢

unread,
Aug 10, 2011, 10:08:32 AM8/10/11
to google-visua...@googlegroups.com
Which parts are causing you problems? As I mentioned, the main issue (causing the 'script too large' error you notice in Firebug) is in the amount of data you download from your fusion table. Currently you are pulling only one column ('geometry') which results in a very big download because it contains kml data. Ideally you should avoid downloading such column and use an alternative representation of the data you are trying to fetch so that the amount of data on the wire goes down to a manageable amount. But that really depends on what you are trying to achieve after you downloaded the fusion tables data.

For example, if the only information you need is the centroid of every zipcode region, you could replace the 'geometry' column with 2 numeric columns containing the latlong of the centroid, hence avoiding the need to download the whole kml.

/R.
Reply all
Reply to author
Forward
0 new messages