3

I have configured my application to use Highcharts client side export (https://www.highcharts.com/docs/export-module/client-side-export), on page load I create a chart and call the exportChart method as shown in this example (http://jsfiddle.net/5dry1oqg/1/).

My problem is that I don't want to download the image immediately, instead I want to use it in a print version which could be called later. What I need to know is if there is a way of intercepting the download, for instance when a Blob is created (if that's what happens).

I suspect there isn't as I don't find any documentation on this from Highcharts, any help appreciated.

Scott Francis
  • 49
  • 1
  • 2
  • 1
    I believe you can prevent the default event by event.preventDefault() for that click event. Then write down your own method to create a print view. To create a print view of a div or dom element, you can refer to https://stackoverflow.com/questions/2255291/print-the-contents-of-a-div – Vinay Gayakwad Aug 21 '18 at 09:49
  • Please describe more precisely the process steps which you have to do, because I don't understand the question a bit. – daniel_s Aug 22 '18 at 11:43

1 Answers1

1

When you trigger exportChart a POST request is being sent to the highcharts servers, containing the SVG and some other values within the request body. I've checked the URL which is being called (export.highcharts.com) and it's a kind of a playground for chart exporting. There if you click on download, you can easily see that first a POST request is being fired with some data (JSON) as request payload (Inspect the call in Network tab). As a response you get the generated image string (e.g. charts/chart.20bb843a8be6440e99ffcab5996c532d.png), therefore your exported image can be accessed via the base-url (https://export.highcharts.com/) + the response of the POST call.

Example: https://export.highcharts.com/charts/chart.20bb843a8be6440e99ffcab5996c532d.png

I'm not 100% sure how legit this workaround is, but you can at least play around with it and maybe find a better/more suitable solution.

Ramiz Wachtler
  • 5,623
  • 2
  • 28
  • 33