title: Update chart based on dropdown selection - javascript
body: <p>I need to update the chart based on dropdown change.
  i dont know how to do in javascript or jquery.</p>
  
  <p>i have created fiddle to explain my situation</p>
  
  <p><strong><a href="http://jsfiddle.net/sELst/25/" rel="nofollow">http://jsfiddle.net/sELst/25/</a></strong></p>
  
  <p>this is the html</p>
  
  <pre><code>&lt;select id="chartType"&gt;
  &lt;option&gt;bar chart&lt;/option&gt;
  &lt;option&gt;area chart&lt;/option&gt;
  &lt;option&gt;line chart&lt;/option&gt;
  &lt;option&gt;spline chart&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;div id="chart"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var chart = c3.generate({
      data: {
          rows: [
              ['data4', 'data2', 'data3'],
              [90, 120, 300],
              [40, 160, 240],
              [50, 200, 290],
              [120, 160, 230],
              [80, 130, 300],
              [90, 220, 320]
          ],
          type: 'bar'
      }
  });
  </code></pre>
  
  <p>this is my customisation , trying</p>
  
  <pre><code>var currentChart = 0;
  var charts = [{
      type: 'line',
      data: 'data4'
  }, {
      type: 'area',
      data: 'data2'
  }, {
      type: 'spline',
      data: 'data3'
  }];
  
  $(function () {
      $("#chartType").change(function (evt) {
          var chartSelection = $("#chartType").val();
          $('#chart').hide().filter(charts + chartSelection).show();
      });
  });
  </code></pre>
  
  <p><strong>in detail explanation</strong></p>
  
  <p>i am working on c3.js charts</p>
  
  <p>in c3, it has 4 kinds of charts</p>
  
  <ol>
  <li>bar chart</li>
  <li>area chart</li>
  <li>spline chart</li>
  <li>line chart</li>
  </ol>
  
  <p>whenever user changes the dropdown or select the other charts i need to update the chart.</p>
  
  <p>C3 library link</p>
  
  <p><strong><a href="http://c3js.org/samples/chart_combination.html" rel="nofollow">http://c3js.org/samples/chart_combination.html</a></strong></p>
  
  <p>Any help is appreciated</p>