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

ERROR TypeError: Cannot read property 'forExport' of undefined

Open pedrocleto opened this issue 5 years ago • 6 comments

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 avatar May 03 '19 11:05 pedrocleto

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

pedrocleto avatar May 09 '19 10:05 pedrocleto

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); } ...

ahlen78 avatar Sep 20 '19 13:09 ahlen78

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

karolinatomczak avatar Dec 06 '19 15:12 karolinatomczak

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

maximsondv avatar Jan 08 '20 08:01 maximsondv

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

RiccardoCampese avatar Mar 10 '20 14:03 RiccardoCampese

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

jusvit avatar Dec 08 '20 01:12 jusvit