Yash Jain
Yash Jain

Reputation: 822

how to add height and width to highchart dynamically

I am using angular-highcharts, in this we have options like addSeries(), removeSeries(), addPoint() etc. but nothing like add height and width. In angular-highchart, there are some issues that if I'm working with widgets having full screen option. When the widget goes fullscreen inside which the highchart is there, the highchart doesn't take the parent height and width i.e. Widget's height and width.

Normally, I can give height and width like this:

chart:{
   type:'bar',
   height:600,
   width:1450
}, 

So, is there any solution that how I can add height and width dynamically in highcharts.

Upvotes: 1

Views: 2368

Answers (1)

LPZadkiel
LPZadkiel

Reputation: 571

there is no setHeight or setWidth but there is a setSize:

setSize( [width] [, height] [, animation]). Example:

chart.setSize(chartWidth, chartHeight);

here is an jsfiddle testing setSize

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/members/chart-setsize-button/

also there is an 'update' function where you can update almost every option of the chart, here is an jsfiddle showing how:

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/members/chart-update/

Upvotes: 1

Related Questions