kartikeys
Posts: 14
Joined: Thu Aug 10, 2023 10:33 am

Export chart not currently rendered

Tue Sep 19, 2023 10:10 pm

Hi Team,

I have been using the highcharts exporting module to export charts locally and it works great :D

In my app, I conditionally switch between a bar chart & a scatter chart showing only one at a time. Since it's an angular app, I use `ng-if` to switch between the charts. Now, highcharts export works well when i am exporting the currently rendered chart. But I am unable to export the currently non-rendered chart since the chart instance is not defined at the time of export.

Is there a way to successfully export non-rendered charts in highcharts ? Thanks.

kamil.k
Posts: 410
Joined: Thu Oct 06, 2022 12:49 pm

Re: Export chart not currently rendered

Wed Sep 20, 2023 11:42 am

Hello kartikeys!

Thanks for your question and kind words about our product.

First, I'd think of how the chart is being hidden because there's a chart instance needed to export a chart. I'd recommend simply hiding the chart using styling to keep that instance and then referring to it to export the chart, take a look: https://jsfiddle.net/BlackLabel/tcp4Lj2d/. As you can see, all these instances are available on a global Highcharts object.

Here's a reference to methods available on a chart instance: https://api.highcharts.com/class-refere ... hart#toc35.

Let me know if this solution meets your needs,
Kind Regards!
Kamil Kubik
Highcharts Developer

kartikeys
Posts: 14
Joined: Thu Aug 10, 2023 10:33 am

Re: Export chart not currently rendered

Fri Sep 22, 2023 11:21 am

Hello Kamil,

I have been able to use your solution to devise a resolution. Thank you :) .

I am now trying to export multiple hidden charts at once as a pdf . For multiple chart exports, i need the charts to be converted to an image format (base64 encoded data), so i can add it to a pdf using jsPDF ( https://artskydj.github.io/jsPDF/docs/m ... Image.html). Is there any way to save the charts in this format instead of exporting them locally with the export module. I cannot directly use highcharts export module since i need non-chart elements (such as a table element ) to also be exported in the same pdf before saving.

Again, thank you for helping out here Kamil. Much appreciated :-)

kamil.k
Posts: 410
Joined: Thu Oct 06, 2022 12:49 pm

Re: Export chart not currently rendered

Fri Sep 22, 2023 3:27 pm

I'm glad the solution works for you!

We already have an up-to-date topic related, and as we try not to duplicate them, I'd like to refer you to this: viewtopic.php?t=39980. A very straightforward solution to get the base64 format is provided in the demo from the latest answer.

Let me know if you face any difficulties implementing it in your case,
Regards!
Kamil Kubik
Highcharts Developer

kartikeys
Posts: 14
Joined: Thu Aug 10, 2023 10:33 am

Re: Export chart not currently rendered

Tue Oct 03, 2023 11:15 am

Hello Kamil,

I could successfully complete multiple exports with your recommendation. Thank you for all your help :).

Return to “Highcharts Usage”