Highcharts Demo

author(s): Torstein Hønsi

by Geo George

HTML

<div id="container"></div>

<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>

CSS

#container {
    height: 500px; 
    width: 800px;
    margin: 0 auto; 
}
.loading {
    margin-top: 10em;
    text-align: center;
    color: gray;
}

JavaScript

let chart;
Highcharts.getJSON('https://cdn.jsdelivr.net/gh/highcharts/[email protected]/samples/data/world-population-density.json', function (data) {

    // Initialize the chart
    chart = Highcharts.mapChart('container', {

        title: {
            text: 'Get MapView state'
        },
        mapView: {
            //zoom: 1
        },

        colorAxis: {
            min: 1,
            max: 1000,
            type: 'logarithmic'
        },

        mapNavigation: {
            enabled: true
        },
				plotOptions:{
        		series:{
            	dataLabels:{
              	enabled:false,
                formatter:function(){
                	return this.point.name
                }
              }
            }
        },
        series: [{
            data:[],
            mapData: Highcharts.maps['custom/world'],
            joinBy: ['iso-a2', 'code'],
            name: 'Population density',
            nullColor:"#f2f2f2",
            borderColor: "#000",
            states: {
                hover: {
                    color: '#a4edba'
                }
            },
            tooltip: {
                valueSuffix: '/km²'
            }
        }]
    });

    
});