highcharts resize
时间: 2023-09-14 17:02:40 浏览: 122
highcharts.js
To resize a Highcharts chart, you can use the `setSize` method provided by the Highcharts API. Here's an example of how you can resize a chart using JavaScript:
```javascript
// Assuming you have a reference to your chart object
var chart = Highcharts.chart('container', {
// chart configuration options...
});
// Resize the chart to a specified width and height
function resizeChart(width, height) {
chart.setSize(width, height);
}
// Usage example: resize the chart to 800px width and 400px height
resizeChart(800, 400);
```
In this example, `chart` refers to the Highcharts chart object, `'container'` is the ID of the HTML element that contains the chart, and `resizeChart` is a function that resizes the chart based on the provided width and height values.
Note that calling `setSize` will redraw the chart with the new dimensions, so make sure to adjust the size accordingly to prevent distortion or other display issues.
阅读全文