简体   繁体   English

使用一个请求导出多个图表

[英]Export multiple charts with one request

On page I have 2 charts. 在页面上我有2个图表。 They are build with Highcharts library. 它们是使用Highcharts库构建的。

I need to export them all as PNG files. 我需要将它们全部导出为PNG文件。 So I add button, on click on which I need to have 2 separate png-files. 所以我添加按钮,点击我需要有2个单独的png文件。

I have function : 我有功能:

myApp.highchart.export.create = function (elementId, filename) {
    var chart = $(elementId).highcharts();
    chart.exportChart({ type: 'image/png', filename: filename, sourceWidth: chart.chartWidth });
}

I pass in this function Id of every chart, but in result I always get only last chart... I try to add timeout but this doesn't help. 我传递了每个图表的这个函数ID,但结果我总是得到最后一个图表...我尝试添加timeout但这没有帮助。

I took a look into Network tab in browser and always see only 1 request to http://export.highcharts.com/ 我在浏览器中查看了“网络”选项卡,并始终只看到1个请求到http://export.highcharts.com/

Can somebody help me with it? 有人可以帮我吗?


Here is example where export for 2 charts works, but in my case this also doesn't help (in example it is used some plugin highcharts-export-clientside but I use simple exporting.js) 这里是两个图表的导出工作的示例,但在我的情况下,这也没有帮助(例如,它使用了一些插件highcharts-export-clientside但我使用简单的highcharts-export-clientside


UPD : I've added highcharts-export-clientside plugin, but still use highcharts method exportChart (in plugin there are exportChartLocal ). UPD:我添加highcharts-export-clientside的插件,但仍使用highcharts方法exportChart (在插件有exportChartLocal )。 With this plugin It is possible to export multiple charts, but in png I get bad formatter chart, all my styles are broken. 使用这个插件可以导出多个图表,但是在png我得到了糟糕的格式化图表,我的所有样式都被打破了。 So I don't know what influence has this plugin when I don't use any of it methods. 所以当我不使用任何方法时,我不知道这个插件有什么影响。


Also seems like multiple export works in FF but not in Chrome. 似乎多个导出工作在FF但不在Chrome中。


Example of simple logic : http://jsfiddle.net/6mn2j5pL/ 简单逻辑的例子: http//jsfiddle.net/6mn2j5pL/

This might help you fix it. 这可能有助于您解决它。

You can use Highcharts.charts for getting array of your charts. 您可以使用Highcharts.charts获取图表数组。 Then you can use Highcharts.each for looping over your charts and exporting them one after other. 然后,您可以使用Highcharts.each循环遍历图表并一个接一个地导出它们。

http://forum.highcharts.com/highcharts-usage/how-to-export-multiple-charts-to-separate-image-files-t35191/ http://forum.highcharts.com/highcharts-usage/how-to-export-multiple-charts-to-separate-image-files-t35191/

Solution provided in this forum seems to be working on chrome as well. 此论坛中提供的解决方案似乎也在使用chrome。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM