TypeError: Highcharts.mapChart is not a function

TypeError: Highcharts.mapChart is not a function



I am trying to plot a highmap in react using typescript. I have additionally loaded the highcharts types which include highmaps.


class InvestmentChart extends React.Component {
componentDidMount() {
Highcharts.mapChart("investment", {
chart: {
...



Cheers



See live here.






Always post relevant code in the question itself. You can still use code snippet here in SO.

– Bhojendra Rauniyar
Aug 31 '18 at 12:18





1 Answer
1



Based on the readme, it looks like you need to do:


import * as Highcharts from 'highcharts/highmaps';



instead of:


import * as Highcharts from 'highcharts';



I tried this in CodeSandbox and it seemed to get past the point where you were stuck.



DefinitelyTyped appears to have some typings for Highmaps, though they are out of date. The following method of importing Highmaps seems to get as far as the previous method at runtime in CodeSandbox and will use the typings:


import * as Highcharts from "highcharts";
import MapFactory = require("highcharts/modules/map");
(MapFactory as any)(Highcharts);



New CodeSandbox. Locally, I am still getting a type error because of the out-of-date declarations (subtitle is not recognized), but you can //@ts-ignore it. I don't know why this error isn't appearing on CodeSandbox.


subtitle


//@ts-ignore






Well ok, but there is no such module. That is the result when trying in CodeSandbox

– Peterhack
Aug 31 '18 at 13:09






See the CodeSandbox I linked where it's working for me.

– Matt McCutchen
Aug 31 '18 at 13:19






You can actually see the map of germany?

– Peterhack
Aug 31 '18 at 13:21






No, but I see the title "Highmaps basic demo" that demonstrates that the Highcharts.mapChart call is doing something. Maybe you are not specifying the map correctly, but that's a different issue.

– Matt McCutchen
Aug 31 '18 at 13:28


Highcharts.mapChart






On my local environment, I still do not get it past that point. The issue is: Could not find a declaration file for module 'highcharts/highmaps'. 'D:/Programming/Bitbucket/report-example/node_modules/highcharts/highmaps.js' implicitly has an 'any' type. Is this related to the same issue as in CodeSandbox that there is no such modul?

– Peterhack
Sep 6 '18 at 11:46


Could not find a declaration file for module 'highcharts/highmaps'. 'D:/Programming/Bitbucket/report-example/node_modules/highcharts/highmaps.js' implicitly has an 'any' type.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế