<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/css/c3.css">
  </head>
  <body>
    <div id="chart"></div>
    <button onclick="load()">Load</button>

    <script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
    <script src="/js/c3.js"></script>
    <script>

      var chart = c3.generate({
        bindto: '#chart',
        data: {
          columns: [
            generateData(100)
          ],
        },
        axis: {
          x: {
            type: 'category'
          }
        },
        zoom: { enabled: true },
        subchart: { show: true }
      });

      function load() {
        chart.load({
          columns: [
            generateData(Math.random() * 1000)
          ],
        });
      }

      function generateData(n) {
        var column = ['sample'];
        for (var i = 0; i < n; i++) {
          column.push(Math.random() * 500);
        }
        return column;
      }

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