This is a topic that pops up frequently here in the forum. Many users have the need to convert/serialize the interactive charts they generate using the Google Charts Tools API into static images (PNGs or equivalent) for the user to download or further process.
Currently the interactive charts API do not offer this feature (unless you are in specific domains, such as within a Google Apps Script<http://code.google.com/googleapps/appsscript/>script), unless you are willing to regenerate your chart using the static image APIs <http://code.google.com/apis/chart/image/> --- which however have different semantics, making it difficult to support both. A quick workaround for this is to convert the SVG chart to <canvas /> and then extract the image data from there. This allows for full client-side pure javascript image serialization, at the cost of cross-browser support. The solution works on Chrome,Safari,Firefox,IE9 and Opera, but IE8 and lower does not support the necessary features for this to work (server-side image serialization is also possible, although I won't discuss it here). I have written a brief tutorial and example page to show how this work. Depending on the browsers your users use, and how flexible you can be, the solution might be good enough for your case. Tutorial : http://www.battlehorse.net/page/topics/charts/save_google_charts_as_image.html Example page: http://www.battlehorse.net/attach/topics/charts/google_charts_to_image.html Source code : https://gist.github.com/1333906 Please note that this is somewhat an hack that I put together in the spare time based on the popularity of topic and lack of support in the current official API, so use at your own risk. Have a look at the tutorial for the limitations. If I were to support image serialization for a production service, I'd still recommend using the static image APIs mentioned above. Please discuss / comment / improve. - 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/-/8kJwHA9OQwsJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
