Highcharts Demo
author(s):
Torstein Hønsi
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>
<button id="selectnor">Select Norway</button>
<button id="selectswe">Select Sweden</button>
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/highcharts@v7.0.0/samples/data/world-population-density.json', function (data) {
for(var i = 0; i < data.length; i++) {
// Adding ID to data, so we can use "get" to find the points
data[i].id = data[i].code3;
}
// Initiate the chart
var chart = Highcharts.mapChart('container', {
series: [{
data: data,
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
allowPointSelect: true,
}]
});
$('#selectnor').click(function () {
chart.get('NOR').select();
});
$('#selectswe').click(function () {
chart.get('SWE').select();
});
});