6
$('#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 我正在使用这个小提琴,我想得到国家名称在国家点击事件。任何人都可以通过示例或链接到此 API 来帮助我吗?我阅读了 API 但找不到,我想我错过了一些观点。提前致谢

4

1 回答 1

17

很简单,只要加上这个:

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

点范围内的this代表单击的点,因此您可以访问它的属性。

http://jsfiddle.net/farz5vq2/

于 2015-10-24T07:20:20.510 回答