As of now, the current supported of function to convert the chart of Google which is
getImageURI()
is the corecharts and geo-chart. The others, including timeline chart is not included on the list. It took me a while to figure it out that getImageURI() is not supported. So what is the alternative on converting the Google Chart Timeline to Image. How do you get the image uri from the timeline chart? Any advice guys?
I tried using html2canvas but seems like the chart is not captured as expected. This is what I've used.
var chartArea = document.getElementsByTagName('iframe')[0].
contentDocument.getElementById('chartArea');
var svg = chartArea.innerHTML;
var canvas = doc.createElement('canvas');
canvas.setAttribute('width', chartArea.offsetWidth);
canvas.setAttribute('height', chartArea.offsetHeight);
canvas.setAttribute(
'style',
'position: absolute; ' +
'top: ' + (-chartArea.offsetHeight * 2) + 'px;' +
'left: ' + (-chartArea.offsetWidth * 2) + 'px;');
doc.body.appendChild(canvas);
canvg(canvas, svg);
var imgData = canvas.toDataURL("image/png");
return imgData;
Any help?
'ready'event before running the above code? - WhiteHat