How to catch the click event from the axis ticks j

2019-03-22 04:31发布

I want to be able to catch the clicked event that is hooked to all the axis ticks. here is what i have done so far.

http://jsfiddle.net/grVFk/5074/

If anyone knows how to do that with any of the charting plugins can kindly share.

thanks

1条回答
甜甜的少女心
2楼-- · 2019-03-22 05:16

the plot isn't plain HTML. So there is no a tag. And the plot itself do not provide you with an api to catch the click event on an axis tick.

What you can do is to select the axis tick manually with jQuery and add a click event:

$('.highcharts-axis tspan').each(function(){
    var label = $(this),
        value = label.text();
    if(categoryLinks[value]) {
        label.click(function(){
            // you' free to what you want...
            alert('could link to another page: ' + categoryLinks[value]);
        });
    }
});

And there is the solution: http://jsfiddle.net/scheffield/grVFk/5090/

查看更多
登录 后发表回答