Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Charts as Image

I am trying to use Google charts to embed images of charts in the emails. So Each user will have a unique graph.

Can we use the API and embed a unique URL that will render the Charts and deliver an Image to the email Client.

like image 586
Harsha M V Avatar asked Jul 02 '12 15:07

Harsha M V


1 Answers

You can get a PNG version of your chart using chart.getImageURI() like following:

Needs to be after the chart is drawn, so in the ready event!

var my_div = document.getElementById('my_div');
var my_chart = new google.visualization.ChartType(chart_div);

google.visualization.events.addListener(my_chart, 'ready', function () {
  my_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
});

my_chart.draw(data);
like image 109
Nathan Q Avatar answered Oct 22 '22 00:10

Nathan Q