Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reset Highchart chart width in percentage on Button click

Tags:

highcharts

I want to change highchart's width on button click, I know I can do it using chart.setSize function, but it sets the width only in pixels. But I need to set the width in percentage.

Here is the sample JSFiddle, in which I have tried to reset the width in 3 ways. Only Button 1 works, but not the remaining 2.

Please let me know how can I reset the width in percentage.

like image 736
shaaaa Avatar asked Mar 24 '23 09:03

shaaaa


1 Answers

you could do it like button4 here :

    var chart = $('#container').highcharts();
    var el = $('.chart-inner');
    el.css('width','100%');
    chart.setSize(el.width(),el.height(),true);
like image 175
ThorHalvor Avatar answered May 01 '23 14:05

ThorHalvor