I have a component where I have to show high maps. No errors but the maps is always empty
My chart options object :
let chartData = [{ code3: "ABW", z: 105 }, { code3: "AFG", z: 35530 }];
this.chartConfigObject = new MapChart(<any>{
chart: {
borderWidth: 1,
map: 'custom/world'
},
title: {
text: 'World population 2013 by country'
},
subtitle: {
text: 'Demo of Highcharts map with bubbles'
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
name: 'Countries',
color: '#E0E0E0',
enableMouseTracking: false
}, {
type: 'mapbubble',
name: 'Population 2016',
joinBy: ['iso-a3', 'code3'],
data: chartData,
map: mapData,
minSize: 4,
maxSize: '12%',
tooltip: {
pointFormat: '{point.properties.hc-a2}: {point.z} thousands'
}
}]
});
When I console the created MapChart object i am getting the series as null always.
What am i missing and why the maps series is always null?
I am using angular-highcharts component as explained here : https://github.com/cebor/angular-highcharts
reproduced in stackblitz: https://stackblitz.com/edit/angular-highcharts-stock-nbvnuw?file=app%2Fapp.module.ts
Might, it can be useful.
Here is the solution for angular-highcharts:
1) Download the map from collection: https://code.highcharts.com/mapdata/
2) Create a variable that equals to the content of this file and export it:
instead of
use
2) Import this map to your component (for world-map.ts):
3) use
And, of course, don't forget to add a couple of lines to your module:
About modules: https://www.npmjs.com/package/angular-highcharts#highmaps
Here is the working example: https://stackblitz.com/edit/angular-highcharts-stock-byjo6a
Solution was found here: https://forum.highcharts.com/highmaps-usage-f14/highmaps-bubble-chart-is-empty-t40432/
You are not providing the map data to your chart , so it doesn't know which map to show. Try showing the map data like
mapData: Highcharts.maps['custom/world']
underSeries
.If you cannot access the maps in your
Highcharts
reference , try importing all the maps (JS files) from theHighMaps
library into your project and reference them in yourtypescript
component file like this:and use
mapData: Highcharts['maps']['custom/world']
or whatever is the map you wanted to use like'countries/us/us-all'
Below is working map code using
angular-highcharts
to plot the map and points on it:Also you need
proj4js
library to plot points on the map, in case if that's your requirement as well.Hope this helps !