Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts: Cannot read property 'parts/Globals.js' of undefined

I am using certain libraries from Highcharts and I get the following error:

Uncaught TypeError: Cannot read property 'parts/Globals.js' of 
undefined
at map.src.js:31
at map.src.js:22
at map.src.js:11

How can I fix this? I am using:

<script src="https://code.highcharts.com/maps/modules/map.js"></script>
like image 543
Shiv Bhandari Avatar asked Apr 02 '19 20:04

Shiv Bhandari


2 Answers

If you encounter this error, you might want to check that your app is not server rendered. In the case that it is server rendered then the following should fix the issue:

Check that highcharts is a type of 'object', because on the server it is of type 'function'. If it is an object then you want to execute the module you want. Kindly see below:

import Highcharts from 'highcharts/highcharts';
import HighchartsReact from 'highcharts-react-official';
import highchartsBellCurve from 'highcharts/modules/histogram-bellcurve';

if (typeof Highcharts === 'object') {
  highchartsBellCurve(Highcharts); // Execute the bell curve module
}
like image 183
codejockie Avatar answered Nov 16 '22 16:11

codejockie


Faced the same issue. Highcharts released a new version 7.1.0 two days back. They have fixed an issue(10232) which is causing this error. You can use https://code.highcharts.com/5.0.14/modules/solid-gauge.js this particular version instead of the latest one. It's working for me now.

like image 6
Vishak Kavalur Avatar answered Nov 16 '22 18:11

Vishak Kavalur