title: How do I use D3 with JavaScript events
body: <p>Am trying to draw d3 charts when a button is clicked.
  But all the d3 tutorials I've seen says the d3 code should be placed inside the element
  you want the charts to appear. This means the d3 code will execute when the page loads but I
  want the code to run only when a button is clicked.</p>
  
  <p>I also want to know if I can place my d3 code in an external file wrapped in a function 
  that I can call when I want to. If no, how do i create button that will show a d3 chart when clicked?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="button" Value="show" /&gt;
  
  &lt;div id="presentation"&gt;
  &lt;!-- bar charts to show up here when the "show" button is clicked.
       The button makes an ajax call and gets a json that contains data
       that will be used to draw the chart.
   --&gt;
  &lt;/div&gt;
  </code></pre>