chart resize on window resize event after setting a specific size - Javascript highcharts

Javascript examples for highcharts:Chart Event

Description

chart resize on window resize event after setting a specific size

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-2.0.2.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <style id="compiled-css" type="text/css">

#btn{/*from w  w w.  ja v  a  2  s  . c o m*/
   background: red;
   color: #fff;
   font-size: 18px;
   border: none;
   cursor: pointer;
}
#container{
   border: 1px solid #f00;
   width: 66%;
   overflow: hidden;
}


      </style> 
      <script type="text/javascript">
    $(window).load(function(){
$(document).ready(function(){
    var chart = $('#container').highcharts({
        tooltip: {
            valueSuffix: '?C'
        },
        series: [{
            name: 'Tokyo',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        }]
    });
    $('#btn').on('click', function(){
        $('#container').highcharts().setSize(330,250);
        $('#container').highcharts().hasUserSize = false;
    });
});
    });

      </script> 
   </head> 
   <body> 
      <button id="btn">Set size</button> 
      <div id="container"></div>  
   </body>
</html>

Related Tutorials