当前位置: 动力学知识库 > 问答 > 编程问答 >

How do you get the mouse hovered label value with the highcharts custom event plugin?

问题描述:

I am using highchars.js and the custom-event plugin.

I add a mouseover event handler on the xAxis label. How can I get the hovered label value in the event handler? Thanks.

https://jsbin.com/havezujuva/edit?html,js,output

xAxis: {

categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],

labels:{

events: {

mouseover: function (e) {

console.log('over');

}

}

}

}

网友答案:

You can access it from this.axis.categories[this.value].

xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],

        labels:{
            events: {
                mouseover: function (e) {
                    console.log('over');
                    console.log(this.axis.categories[this.value]);
                }
            }               
        }

    }
分享给朋友:
您可能感兴趣的文章:
随机阅读: