微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 在使用highcharts库制作的图表上添加onclick事件

我想知道如何在使用highcharts lib制作的整个图表上添加点击事件.

最佳答案
您可以使用图表click事件.

参考:

Fires when clicking on the plot background. The this keyword refers to
the chart object itself. One parameter,event,is passed to the
function. This contains common event information based on jQuery or
MooTools depending on which library is used as the base for
Highcharts.

information on the clicked spot can be found through event.xAxis and
event.yAxis,which are arrays containing the axes of each dimension
and each axis’ value at the clicked spot. The primary axes are
event.xAxis[0] and event.yAxis[0]. Remember the unit of a datetime
axis is milliseconds since 1970-01-01 00:00:00.

码:

chart: {
    type: 'column',events: {
        click: function () {
            alert('chart clicked');
        }            
    }
}

演示:http://jsfiddle.net/DYNhr/

原文地址:https://www.jb51.cc/js/429823.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐