cebor / angular-highcharts

Highcharts directive for Angular
MIT License
213 stars 63 forks source link

ERROR TypeError: Cannot read property 'forExport' of undefined #289

Open pedrocleto opened 5 years ago

pedrocleto commented 5 years ago

This line is causing the chart to break and throw an error when using the export functionality. Using the latest highcharts 7.1.1 and angular-highcharts 7.2.0 https://github.com/cebor/angular-highcharts/blob/29ea31a9520709fde8a19138ba84c428127587a3/projects/angular-highcharts/src/lib/chart.ts#L90

ERROR TypeError: Cannot read property 'forExport' of undefined at a.Chart.destroy (highcharts.js:293) at FlowChart.push../node_modules/angular-highcharts/fesm5/angular-highcharts.js.Chart.destroy (angular-highcharts.js:169) at ChartDirective.destroy (angular-highcharts.js:384) at ChartDirective.ngOnDestroy (angular-highcharts.js:359) at callProviderLifecycles (core.js:20988) at callElementProvidersLifecycles (core.js:20956) at callLifecycleHooksChildrenFirst (core.js:2094

pedrocleto commented 5 years ago

Destroy shouldn't be called in this function it is causing all problems with exporting

ahlen78 commented 4 years ago

As a workaround you do this to your chart options: ... exporting { ... menuItemDefinitions: {"printChart": {}, "separator": {}, "downloadPNG": { onclick : function() { this.exportChart(); this.options.reload(); }}, "downloadJPEG": { onclick : function() { this.exportChart({type: 'image/jpeg'}); this.options.reload(); } }, "downloadPDF": { onclick : function() { this.exportChart({type: 'application/pdf'}); this.options.reload(); }}, "downloadSVG": { onclick : function() { this.exportChart({type: 'image/svg+xml'}); this.options.reload(); } }} } ... options['reload'] = () => { this.chart= new Chart(options); } ...

karolinatomczak commented 4 years ago

What is the status of this bug? Are you planning to work on it?

maximsondv commented 4 years ago

Im also having this issue, will this bug be fixed?

RiccardoCampese commented 4 years ago

As a workaround you do this to your chart options: ... exporting { ... menuItemDefinitions: {"printChart": {}, "separator": {}, "downloadPNG": { onclick : function() { this.exportChart(); this.options.reload(); }}, "downloadJPEG": { onclick : function() { this.exportChart({type: 'image/jpeg'}); this.options.reload(); } }, "downloadPDF": { onclick : function() { this.exportChart({type: 'application/pdf'}); this.options.reload(); }}, "downloadSVG": { onclick : function() { this.exportChart({type: 'image/svg+xml'}); this.options.reload(); } }} } ... options['reload'] = () => { this.chart= new Chart(options); } ...

Does anyone know if this is valid? And if so, can they make it more clear? I don't understand what am I supposed to do with this piece of code... should I reinstantiate every single options chart like every single time after exporting? Or do I need to set those options on every single chart?

I don't understand this workaround or how to implement it

jusvit commented 3 years ago

Updated my angular-highcharts to 9.0.11 from 8.0.3 fixed this for me.