Sabira
Sabira

Reputation: 103

Highcharts - how to export chart with different scale in one click

I am trying to download one chart with different scales in one click. I have an array of scales and I loop over them and export chart each iteration with corresponding scale. However, chart gets downloaded once and scaled by 3 which is the last element of the scales array.

const scales = [1,2,3];
const exportChart = (scale) => chart.exportChart({scale});
$('button.export').click( function () {
 scales.forEach(exportChart)
});

I assume I'm not allowed to export chart multiple times. Appreciate if someone can help me with that. Thanks!

Here is my fiddle https://jsfiddle.net/sabira/bf6yLcxw/

Upvotes: 2

Views: 400

Answers (1)

pawel_d
pawel_d

Reputation: 3070

You can export and save separately multiple charts by clicking on a button. The reason why you get only one image is because you're trying to send multiple requests to the server at once, therefore only one success and the rest are canceled. Instead of sending POST requests to the server you can use the offline exporting module's method, exportChartLocal which does all the export stuff locally. I have prepared a simple example which can be found below.

Example:
https://jsfiddle.net/BlackLabel/w5boxq13/

Upvotes: 1

Related Questions