用图像替换highcharts报告?

时间:2017-04-24 16:44:40

标签: highcharts

我要将大约100个图表导出到可打印的报告中。在Internet Explorer中拥有100个图表的速度很慢。这有什么解决方法吗?

1 个答案:

答案 0 :(得分:0)

您可以将POST请求发送到导出服务器,以便导出所有图表,而无需在浏览器中实际呈现它们。

const options = {
  chart: {},
  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],
    type: 'column'
  }]
}
const data = {
    options: JSON.stringify(options),
    filename: 'test.png',
    type: 'image/png',
    async: true
}
const exportUrl = 'https://export.highcharts.com/'
$.post(exportUrl, data, function(data) {
    const imageUrl = exportUrl + data
    const urlCreator = window.URL || window.webkitURL
    document.querySelector("#image").src = imageUrl
})

// You can uncomment in order to render chart
// const chart = Highcharts.chart('container', options)

实例: https://jsfiddle.net/28098mfj/