How to dynamically change the size of a Highcharts chart
Set the margin property of the chart, the code is as follows ;
view sourceprint?
$(function () {
$('#container').highcharts({
chart: {
type: 'line',
margin: [0, 0, 0, 0 ] //The distance value from top, bottom, left and right
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', ' Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
In this way, the height and width of the chart do not need to be set, only the value of the div needs to be set.
<div id="container" style="height: 400px"></div>