I’ve used Highcharts quite a bit and the charts work great, but I’ve been stuck trying to make Highmaps work for quite a while now.
I believe I have everything setup correctly with my test map that I’m trying to make work because it works correctly in JSFiddle.
The error I’m receiving in my browser console is this:
“Uncaught ReferenceError: Highcharts is not defined at
https://code.highcharts.com/mapdata/custom/world-highres.js:1:1 (anonymous function) @ world-highres.js:1”
The first part of world-highres.js is: Highcharts.maps["custom/world-highres"] = { ...
Does anyone know why Highcharts would be coming back as undefined here?
I’m using Meteor 1.3.5.1 and I have Highcharts 5.0.4 installed through NPM.
Here’s how I currently have things setup:
exampleTemplate.js
import Highcharts from 'highcharts';
require('highcharts/modules/map')(Highcharts);
Template.exampleTemplate.onRendered(function() {
// Example data
var mymapdata = [
{
key: "US",
value: 198812
},
{
key: "GB",
value: 52894
},
{
key: "CA",
value: 35572
}
];
// Initiate
Highcharts.mapChart('country-map-container', {
title: {
text: 'Highmaps Example'
},
subtitle: {
text: 'Example'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series: [{
data: mymapdata,
mapData: Highcharts.maps['custom/world-highres'],
joinBy: ['iso-a2', 'key'],
name: 'Random data',
states: {
hover: {
color: '#a4edba'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
});
exampleTemplate.html
<template name="exampleTemplate">
<div id="country-map-container" style="width:100%; height:400px;"></div>
</template>
Head tag:
<head>
<script src="https://code.highcharts.com/mapdata/custom/world-highres.js"></script>
</head>
Here’s what it looks like with the code above:
I’ve tried a lot of different things and spent a ton of time on this but nothing I’ve tried seems to make it work… Any help with this would be extremely appreciated.