Google chart setOnLoadCallback - Javascript Google Chart

Javascript examples for Google Chart:Chart Configuration

Description

Google chart setOnLoadCallback

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Bar Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script> 
      <div id="content" style="width: 900px; height: 500px;"></div> 
      <script type="text/javascript">
function draw()/*from   www. j a  v  a  2  s. com*/
  {
   google.load('visualization', '1.0', {'packages':['corechart']});
   google.setOnLoadCallback(function (){
      console.log("callback");
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'header');
      data.addColumn('number', 'percntile');
      data.addRows([
       ['above', 50.1],
       ['below', 49.9]
      ]);
    // Set chart options
    var options = {'title':'tfyfty',
                   'width':400,
                   'height':300
               };
    var chart = new google.visualization.PieChart(document.getElementById('content'));
    chart.draw(data, options);
  });
  }
draw();

      </script>  
   </body>
</html>

Related Tutorials