How to best send data (DataTable and draw-options) to server..?

11 views
Skip to first unread message

codingGirl

unread,
Dec 14, 2009, 9:02:23 AM12/14/09
to Google Visualization API
Hi,

to create a Visualization I need to send data (the DataTable and the
draw-options) to my server and get an image back which I then display
in the website using Javascript.

I a way this is a bit like the Image charts in Google Visualization:
http://code.google.com/apis/visualization/documentation/gallery/genericimagechart.html

I wonder how in that case Google is sending data to their image chart
server? They do not encrypt everything as URL and send a GET request
because that would introduce a limitation in length of data to be send
to something like 2000 chars.

Could somebody explain to me how I should best send this data with
Javascript and how best 'accept' and 'process' it at the server side?

Souce code examples would be great :)

Thanks!

codingGirl

unread,
Dec 16, 2009, 10:51:27 AM12/16/09
to Google Visualization API
Nobody can at least give a hint how to do this?

Markw65

unread,
Dec 16, 2009, 11:28:21 AM12/16/09
to Google Visualization API
Well, actually, encoding the data in the url is /exactly/ how the
image charts work.

And yes, it does mean that the url length is limited - eg ie6 limits
it to 2k on the client side. Also, some servers will limit it
(although I dont think google's chart servers do that).

If you want/need to get around that, you can use "POST" instead of
"GET" with an XMLHttpRequest from javascript. Then you can send
whatever (and however much) data you want.

But then you're outside of the google visualization world, and are
working with your own protocol.

Mark

codingGirl

unread,
Dec 16, 2009, 7:46:00 PM12/16/09
to Google Visualization API
I am not sure I am following you. Google Visualization World doesn't
promise anything about how the data is sent if I am not mistaken.

Also Google Chart and Google Visualization are two different animals.
In fact Google Visualization is using Google Chart for the Image
Charts which are overcoming the 2000k limit - meaning they do not use
GET to send their data.

I wonder what they use?

Markw65

unread,
Dec 16, 2009, 8:05:18 PM12/16/09
to Google Visualization API
Sorry, you're right.

I was thinking about how you get the datatable /for/ a visualization,
which is defined to use GET.

So yes, a visualization could use any method to send its data to a
server (or indeed no method at all, since a lot of them dont require a
server).

So POST is probably the way to go.

Mark

Bug Chart

unread,
Dec 22, 2009, 8:27:59 AM12/22/09
to google-visua...@googlegroups.com
Hi,

so, in GenericImageChart, GET requests are used, and sometimes POST requests as well.
to your original question,
why is that the solution that you want?

if you want to embed a Google Visualization visualization in your page,
and use some data from your server,
then the easiest way is to use the Data Source JAVA Library (http://code.google.com/apis/visualization/documentation/dev/dsl_about.html).

if you're sure you want to send data from the client to the server and get an image from the server
back to the client, than, yes, POST is probably cool.

HTH

BugChart.
Reply all
Reply to author
Forward
0 new messages