5

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>
brasofilo
  • 25,496
  • 15
  • 91
  • 179
Shiv Bhandari
  • 87
  • 1
  • 6

4 Answers4

9

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
}
codejockie
  • 9,020
  • 4
  • 40
  • 46
  • Worked for me thank you. I was using nextJS. – Aniket Jul 07 '22 at 20:30
  • Ran into this issue using highcharts in Storybook vs browser, constantly hitting "Cannot read property 'Core/Color/Color.js' of undefined" in the browser. This fixed it and ended several hours of pain, thank you! – Gee Sep 09 '22 at 10:37
6

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.

Vishak Kavalur
  • 449
  • 1
  • 5
  • 12
0

Yes I was also facing the same issue... i have resolved it by replacing js files with updated version Highcharts JS v7.2.1

0

Happened to me when I was trying to use react-highcharts. To resolve this, I switched to highcharts-react-official instead:

import React from "react";
import { render } from "react-dom";
// Import Highcharts
import Highcharts from "highcharts";
import HighchartSankey from "highcharts/modules/sankey";
import HighchartsWheel from "highcharts/modules/dependency-wheel";
import HighchartsReact from "highcharts-react-official";

HighchartSankey(Highcharts);
HighchartsWheel(Highcharts);

const Viz = () => {
  return (
    <HighchartsReact
      highcharts={Highcharts}
      options={{
        series: [{
          type: "dependencywheel",
          data: [{
            from: "Category1",
            to: "Category2",
            weight: 2
          }, {
            from: "Category1",
            to: "Category3",
            weight: 5
          }]
        }]
      }}
    />
  );
};

render(<Viz />, document.getElementById("root"));
Bugs Bunny
  • 2,496
  • 1
  • 26
  • 32