Here's the afterAnimate code loading the data via addSeries
Code: Select all
const afterAnimate = e => {
const chart = e.target.chart;
if (!chart.get('OvalData')) {
chart.addSeries({
type: 'geoheatmap',
name: 'OvalData',
animation: false,
id: 'OvalData',
colsize: 2,
rowsize: 2,
data: getOvalData()
}, false);
chart.redraw(false);
}
};
Code: Select all
Highcharts.getJSON(
'https://code.highcharts.com/mapdata/custom/world.topo.json',
topology => {
const chart = Highcharts.mapChart('container', {
chart: {
backgroundColor: 'rgba(0,0,0,0.1)',
map: topology
},
title: {
text: ''
},
legend: {
enabled: false
},
mapNavigation: {
enabled: false,
enableDoubleClickZoomTo: false,
buttonOptions: {
verticalAlign: 'bottom'
}
},
mapView: {
maxZoom: 3,
projection: {
name: 'Orthographic',
rotation: userLoc
}
},
tooltip: {
animation: false,
pointFormat: '{point.name}: {point.value}',
borderRadius: 10,
borderWidth: 2,
enabled: false,
enableMouseTracking: false
},
plotOptions: {
series: {
allowPointSelect: true,
nullColor: '#BFCFAD',
states: {
hover: {
enabled: false
},
inactive: {
enabled: false
},
select: {
enabled: false
}
},
animation: {
duration: 250
},
clip: false
},
geoheatmap: {
colorAxis: {
min: 0,
max: 100,
labels: {
enabled: false
},
stops: [
[0, 'rgba(9, 185, 0, .05)'],
[0.16, 'rgba(9, 185, 0, .1)'],
[0.33, 'rgba(9, 185, 0, .4)'],
[0.5, 'rgba(249, 204, 60, .7)'],
[0.66, 'rgba(243, 165, 46, .8)'],
[0.83, 'rgba(238, 104, 47, .8)'],
[1, 'rgba(219, 62, 45, .9)']
]
},
clip: false
}
},
series: [{
name: 'Graticule',
id: 'graticule',
type: 'mapline',
data: getGraticule(),
nullColor: 'rgba(0, 0, 0, 0.05)',
enableMouseTracking: false
}, {
data,
/*joinBy: 'name',
name: 'NothingYet',*/
dataLabels: {
enabled: false,
format: '{point.name}'
},
events: {
afterAnimate
}
}]
});
// Render a circle filled with a radial gradient behind the globe to
// make it appear as the sea around the continents
const renderSea = () => {
let verb = 'animate';
if (!chart.sea) {
chart.sea = chart.renderer
.circle()
.attr({
fill: {
radialGradient: {
cx: 0.4,
cy: 0.4,
r: 1
},
stops: [
[0, 'lightblue'],
[1, '#005477']
]
},
zIndex: -1
})
.add(chart.get('graticule').group);
verb = 'attr';
}
const bounds = chart.get('graticule').bounds,
p1 = chart.mapView.projectedUnitsToPixels({
x: bounds.x1,
y: bounds.y1
}),
p2 = chart.mapView.projectedUnitsToPixels({
x: bounds.x2,
y: bounds.y2
});
chart.sea[verb]({
cx: (p1.x + p2.x) / 2,
cy: (p1.y + p2.y) / 2,
r: Math.min(p2.x - p1.x, p1.y - p2.y) / 2
});
};
renderSea();
Highcharts.addEvent(chart, 'redraw', renderSea);
}
);