Here's my google pie chart. Right now, I can right click and save image as PNG. However I need the image download to happen automatically on a specified folder when the page loads.
I tried various canvas options however couldn't get anything to work.
save google gauge chart as a png
Can someone help?
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</style>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities',
is3D: true
};
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
google.visualization.events.addListener(chart, 'ready', function () {
piechart_3d.innerHTML = '<img src=' + chart.getImageURI() + '>';
});
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="JSFiddle">
<div id="piechart_3d" style="width: 1100px; height: 500px;"></div>
</div>
</body>
</html>