score:0

Highcharts does not support dynamic height, you can achieve it by $(window).resize event:

$(window).resize(function() 
{    
    chart.setSize(
       $(document).width(), 
       $(document).height()/2,
       false
    );   
});

See demo fiddle here.

score:0

You can set chart.height dynamically with chart.update method.

http://api.highcharts.com/highcharts/Chart.update

function resizeChartFromValues (chart) {
  const pixelsForValue = 10
  const axis = chart.yAxis[0]
  chart.update({ chart: { height: (axis.max - axis.min) * pixelsForValue } })
}

const options = {
  chart: {
    events: {
      load () {resizeChartFromValues(this)}
    }
  },
  series: [{
    data: [30, 70, 100],
  }]
}

const chart = Highcharts.chart('container', options)

setTimeout(() => {
  chart.series[0].setData([10, 20, 30])
  resizeChartFromValues(chart)
}, 1000)

Live example: https://jsfiddle.net/a97fgsmc/

score:0

I had the same problem and I fixed it with:

<div id="container" style="width: 100%; height: 100%; position:absolute"></div>

No special options to the chart. The chart fits perfect to the browser even if I resize it.

score:2

here is one example which is resize chart according screen. http://jsfiddle.net/davide_vallicella/LuxFd/2/

Just don't set the height property in HighCharts and it will handle it dynamically for you so long as you set a height on the chart's containing element. It can be a fixed number or a even a percent if position is absolute.

http://api.highcharts.com/highcharts/chart.height

By default the height is calculated from the offset height of the containing element

find example here:- http://jsfiddle.net/wkkAd/149/

#container {
    width:100%;
    height:100%;
    position:absolute;
}

score:2

hey I was using angular 2+ and highchart/highstock v.5, I think it will work in JS or jQuery also, here is a easy solution

HTML

<div id="container">
    <chart type="StockChart" [options]="stockValueOptions"></chart> 
</div>

CSS

#container{
   height: 90%;
} 

TS

 this.stockValueOptions = {
     chart: {
         renderTo: 'container'                    
     },
     yAxis: [{
        height: '60%'
     },{
        top: '65%',
        height: '35%'
     }]
} 

Its working, and a easy one. Remove chart height add height in '%' for the yAxis.


Related Query

More Query from same tag