title: How to plot google chart after clicking a button using a jquery
body: <p>I'm able to plot following chart just out of the box (<a href="https://developers.google.com/chart/interactive/docs/gallery/piechart" rel="nofollow">https://developers.google.com/chart/interactive/docs/gallery/piechart</a>), but when I try to load it via jquery after clicking a button it doesn't work. I read a lot of questions/answers here in stackoverflow and elsewhere in the Internet, but somehow they didin't work to me and I was unable to solve the issue. Nothing is plotted on the screen after clicking the button.</p>
  
  <p>Here the last code I tried:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
          &lt;script&gt;
  
              $(document).ready(function(){
                  $(".btn").click(function(){
  
  
                      google.load("visualization", "1", {packages:["corechart"]});
                      google.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'
                          };
  
                          var chart = new google.visualization.PieChart(document.getElementById('piechart'));
  
                          chart.draw(data, options);
                      }
  
  
                  });
              });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;button class="btn"&gt;Plot chart!&lt;/button&gt;
          &lt;div id="piechart" class="piechart"&gt;Chart would be plotted here&lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I would appreciate any help!</p>