Highmaps get country name on click

$('#container').highcharts('Map', {

        title : {
            text : 'Highmaps basic demo'
        },

        subtitle : {
            text : 'Source map: <a href="http://code.highcharts.com/mapdata/custom/africa.js">Africa</a>'
        },

        mapNavigation: {
            enabled: true,
            buttonOptions: {
                verticalAlign: 'bottom'
            }
        },

        colorAxis: {
            min: 0
        },

        series : [{
            data : data,
            mapData: Highcharts.maps['custom/africa'],
            joinBy: 'hc-key',
            name: 'Random data',
            states: {
                hover: {
                    color: '#BADA55'
                }
            },
            dataLabels: {
                enabled: true,
                format: '{point.name}'
            }
        }]
    });
});

http://jsfiddle.net/gh/get/jquery/1.11.0/highslide-software/highcharts.com/tree/master/samples/mapdata/custom/africa I use this fiddle and I want to get the name of the country in the event click by country. Can anyone help me with an example or API reference for this? I read the API, but could not find, I think I miss some point. thank you in advance

+4
source share
1 answer

Pretty simple, just add this:

    plotOptions:{
        series:{
            point:{
                events:{
                    click: function(){
                        alert(this.name);
                    }
                }
            }
        }
    }

this in the area of ​​a point is a clicking point, so you have access to its properties.

http://jsfiddle.net/farz5vq2/

+11
source

Source: https://habr.com/ru/post/1612983/


All Articles