Highcharts Demo
author(s): Torstein Hønsi
by Umair Rafiq
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/data.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
<div id="container"></div>
CSS
#container {
height: 500px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}
JavaScript
$.getJSON('https://cdn.jsdelivr.net/gh/highcharts/[email protected]/samples/data/world-population-density.json', function (data) {
// Initiate the chart
Highcharts.mapChart('container', {
chart: {
spacing: [0, 0, 0, 0],
margin: [0,0,0,0], plotBackgroundColor: '#E0E0E0'
},
title: {
text: 'Chart with a 100px spacing all around'
},
mapNavigation: {
enabled: true,
buttonOptions: {
alignTo: 'spacingBox',
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 1,
max: 1000,
// type: 'logarithmic'
},
legend: {
title: {
text: 'Population per km²'
}
},
series: [{
data: data,
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
name: 'Population density',
states: {
hover: {
color: '#a4edba'
}
},
tooltip: {
valueSuffix: '/km²'
}
}]
});
});