Save Image file from Image URL for Google Pie chart - Javascript Google Chart

Javascript examples for Google Chart:Pie Chart

Description

Save Image file from Image URL for Google Pie chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from  w  ww  .j  av a2  s. c om*/
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart(){
   var data = new google.visualization.DataTable();
  data.addColumn('string', 'Agecategory');
  data.addColumn('number', 'Percentage');
  data.addRows([
     ['Mushrooms', 3],
    ['Onions', 1],
    ['Olives', 1],
    ['Zucchini', 1],
    ['Pepperoni', 2],
  ]);
  var options = {"title": "How Much Pizza I Ate Last Night", "width": 400, "height": 300};
  var chart_div = document.getElementById('chart_div');
  var chart = new google.visualization.PieChart(chart_div);
  google.visualization.events.addListener(chart, 'ready', function () {
    chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
      console.log(chart_div.innerHTML);
   });
  chart.draw(data, options);
}
    }

      </script> 
   </head> 
   <body> 
      <div id="chart_div"></div>  
   </body>
</html>

Related Tutorials