resize Highstock chart - Javascript highcharts

Javascript examples for highcharts:Stock Chart

Description

resize Highstock chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script> 
      <script type="text/javascript">
$(function() {//from  w w  w.ja  v a 2s .  c o  m
$('#btn').click(function () {
  $('#container').highcharts().setSize(300, null);
});
  $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?a=e&filename=aapl-ohlc.json&callback=?', function(data) {
    // create the chart
    Highcharts.stockChart('container', {
      rangeSelector: {
        selected: 1
      },
      title: {
        text: 'AAPL Stock Price'
      },
      series: [{
        type: 'candlestick',
        name: 'AAPL Stock Price',
        data: data
      }],
      responsive: {
        rules: [{
          chartOptions: {
            plotOptions: {
              series: {
                dataGrouping: {
                  groupPixelWidth: 30
                }
              }
            }
          },
          condition: {
            maxWidth: 300
          }
        }]
      }
    });
  });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <button id="btn">set size </button> 
      <div id="container" style="height: 400px; width:1000px"></div>  
   </body>
</html>

Related Tutorials