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

Highcharts in SSR

Open luiscarreira opened this issue 5 years ago • 0 comments

We needed to adapt our Angular application to support SSR and got an error in this lib. With it current stat, when trying to call a page in SSR mode, this lib will throw the error: "Cannot read property 'parts/Globals.js' of undefined".

After some investigation we found that the problem originates in the chart.service.ts file. Where we now can see:

initModules() { this.chartModules.forEach(chartModule => { chartModule(Highcharts); }); }

Should be changed to:

initModules() { this.chartModules.forEach(chartModule => { if(Highcharts === 'object'){ chartModule(Highcharts); } }); }

As far as we could check, in SSR mode the parameter Highcharts can arrive in the be of type function and in this case the charModule can't execute properly.

luiscarreira avatar Jan 31 '20 16:01 luiscarreira