Serialization of visualizations

45 views
Skip to first unread message

Eric

unread,
Oct 31, 2011, 7:10:20 AM10/31/11
to google-visua...@googlegroups.com
I am using the html examples at

This html I paste into a server page.

How do I load the appropriate libraries and call the methods in order to 
serialize the chart produced?  Please could someone refer me to a *working example*
of html/javascript for this.

I am able to implement this with the examples given for serialization and email but then only as a function in a script editor.
I believe this has to do with my lack of understanding of the javascript and the loading of libraries with google.load.
When I try to include the following code in an html page in the , I get "unexpected Identifier"
or "unknown method getBlob".

First I change the line
new google.visualization.LineChart( ...
to
var myChart =  new google.visualization.LineChart(...

Then in the main function of the linechart example, add the stanzas;

var chartBlob = myChart.getBlob().getBytes();

       var chartFile = [{fileName: "chart.png",
                         mimeType: "image/png",
                          content: chartBlob}];

I would appreciate advice on how to implement this correctly.

Roni Biran

unread,
Oct 31, 2011, 9:16:04 AM10/31/11
to google-visua...@googlegroups.com
according to the I/O 2011 (London GTUG) this feature is supposed to be supported in the future for ChartWrapper (http://www.battlehorse.net/wontlast/gtugChartsLondon/index.html#27), however I don't think it's supported at the moment.

I know for myself, that I need this feature for exporting charts as images.
If you'll find a way to make it work, please let us all know.



--
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/-/-HUmK2on2vwJ.
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.

Riccardo Govoni ☢

unread,
Nov 1, 2011, 11:30:18 AM11/1/11
to google-visua...@googlegroups.com
I think there's a bit of confusion here. What exactly do you mean by 'serializing' the chart ?

If you intend to persist the chart state in same format that can be later rebuilt, this is already available, for example using ChartWrapper.toJSON() . See the sources of this example which draws a chart, serializes it into a json string and then parses it back again to build a clone. 

If you intend converting the chart to image, then indeed that is something that is currently explicitly supported only inside Google Apps Script via the getBlob() method you mentioned. Alternatives way, such as converting the chart svg into <canvas /> and building an image out of that, could probably work, but they are outside the library boundary (read: you have to implement them on your own).

-- R.

Roni Biran

unread,
Nov 1, 2011, 3:16:30 PM11/1/11
to google-visua...@googlegroups.com
I think that Eric meant for the latter, the possibility to save/export a chart as an image.



2011/11/1 Riccardo Govoni ☢ <battl...@gmail.com>

Allomorphy

unread,
Nov 1, 2011, 4:22:02 PM11/1/11
to google-visua...@googlegroups.com
Thank you Riccardo

That answers all my questions regarding serialization (to file).

I am still very confused about support of parameters as of now().

I am trying to milk as much goodness from the Areachart API that I can
right now. So I have tried many of the configuration parameters
listed in http://code.google.com/apis/chart/interactive/docs/gallery/areachart.html

Most cause a failure to generate the image when used in html/js/json
in a web page or cgi script.

Is there a resource where we are able to lookup which of the paramters
are currenlty supported and which not? This would save me the time of
having to test each parameter manually. Or do they all work but I am
just doing something wrong?

Thanks a lot Riccardo.

--
Eric

Allomorphy

unread,
Nov 1, 2011, 5:35:05 PM11/1/11
to google-visua...@googlegroups.com
Please scratch this email.

I discovered what I was doing incorrectly, thanks Roni for pointing me
in the right direction.

The published API is of course functional as expected.

I see the light - thanks.

--
Eric

Reply all
Reply to author
Forward
0 new messages