highcharts-angular icon indicating copy to clipboard operation
highcharts-angular copied to clipboard

Cannot read properties of undefined (reading 'forExport')

Open nisaanwaar opened this issue 2 years ago • 2 comments

Describe the bug

Hi, We are using offline export of highcharts, after exporting chart to any format whenever we route to another component we face subject mentioned exception in console. Updating highcharts is not an option for us now. Other solutions mentioned in this forum for same issue dont seem to work either. I have tried recreating the roblem in stablitz link below, i am updating chart object to null manually to recreate the issue and console will through same error.

Expected behavior

There shouldnt be any problem in destroying the chart component after export.

Demo

https://stackblitz.com/edit/angular-highcharts-events-example-qbrmy2?file=app/hello.component.ts

Steps required to recreate the problem in the demo:

  1. ... Open the stackblitz url, Click on Lets create custom chart click export, open for a few seconds and wait for an alert to appear. after alert i have updated the chart variable to null to trigger destroy of chart. which throws the error.

Setup used

  • NodeJS version ...14.18
  • Angular version ...11 Highcharts 7 "highcharts-angular": "2.10.0",

nisaanwaar avatar Oct 07 '22 14:10 nisaanwaar

Anybody?

nisaanwaar avatar Oct 08 '22 23:10 nisaanwaar

Hi @GurlWhoCodesAlot!

When you are trying to export the chart, a new mock chart is created. This extra new chart is flagged with forExport flag. Richt after the chart is exported this mock chart is destroyed.

Could you please explain why are you trying to do the same manually?

            if (!this.renderer.forExport) {
            } else {
              setTimeout(() => {
                alert('load called for exportsssed chart');
                console.log(this, c);
                c.destroy();
                objRef.createCustomChart(opts);
              }, 5000);
            }

karolkolodziej avatar Oct 10 '22 10:10 karolkolodziej

Closing due to inactivity.

karolkolodziej avatar Feb 01 '23 07:02 karolkolodziej