Where should i put printable version of google chart code on my javascript

37 views
Skip to first unread message

Digimon Indo

unread,
Jul 12, 2017, 12:21:22 AM7/12/17
to Google Visualization API
So i have following this article https://developers.google.com/chart/interactive/docs/printing for exporting my chart into png.
But i have little problem when i put  this code
document.getElementById('png').outerHTML = '<a href="' + chart.getImageURI() + '">Printable version</a>';

,

i dont know where that code must be placed.

My code for exporting chart :

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

I really new on this, and i need your help.
Thank you :)

Digimon Indo

unread,
Jul 12, 2017, 12:23:25 AM7/12/17
to Google Visualization API

My code overview

Ray Thomas

unread,
Jul 13, 2017, 10:35:00 AM7/13/17
to Google Visualization API
The code goes just before the draw method. You also need to add a new div in the HTML to hold the image or link to it.

https://jsfiddle.net/brisray/L01cxut6/ - This shows the code to draw the chart

https://jsfiddle.net/brisray/L01cxut6/3/ - This shows the chart and an image of the chart (the image is the bottom one)

https://jsfiddle.net/brisray/L01cxut6/4/ - This shows the chart and a link to the image of it. The image will open in a new browser tab.

Some of the data may be a little different to what you supplied as I simply OCR'd your screenshot to get it back into text I could use.

Ray


 
Reply all
Reply to author
Forward
0 new messages