感谢@ppotaczek 转发 [this SO post][1],我能够为 React 创建以下解决方案。希望它会在未来帮助别人!
//Start by calling the chart options (using refs) into a variable and JSON stringify
let chartoptions = this.lineChartRef.current.BrokerChart.current.chart.userOptions
chartoptions = JSON.stringify(chartoptions)
//Create a data body with the following parameters
let data = {
options: chartoptions,
filename: 'LineChart',
async: true
}
let url = "https://export.highcharts.com/"
let returnedimageurl = ""
//setState will be called within the Axios return so "This" must
let self = this
axios({
method: 'post',
url: 'https://export.highcharts.com/',
data: data,
})
.then(function (response) {
returnedimageurl= url +response.data
self.setState({
activityChartPng: url
}, self.allowDownload())
})
.catch(function (response) {
//handle error
console.log(response);
});
//The activityChartPvg state can then be passed as props to the React-PDF component
[1]: https://stackoverflow.com/questions/54761784/highcharts-export-multiple-charts-using-jspdf