highmaps在点击事件中获取国家/地区名称

Soh*_*Ali 4 onclick highmaps

$('#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}'
            }
        }]
    });
});
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/gh/get/jquery/1.11.0/highslide-software/highcharts.com/tree/master/samples/mapdata/custom/africa 我正在使用这个小提琴,我想得到国名关于国家的点击事件.任何人都可以帮助我的示例或链接到这个API?我读了API但找不到,我想我错过了一些观点.提前致谢

Mor*_*osh 15

很简单,只需添加:

    plotOptions:{
        series:{
            point:{
                events:{
                    click: function(){
                        alert(this.name);
                    }
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

this在点范围代表单击点,therfore您可以访问它的属性.

http://jsfiddle.net/farz5vq2/

  • 此外,[此处](http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/maps/plotoptions/series-point-events-click-url/) highcharts演示,演示在单击地图点时打开URL。 (2认同)