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

标签 javascript function events highcharts onclick

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

最佳答案

可以用图表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/

关于javascript - 在使用 highcharts 库制作的图表上添加 onclick 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19245781/

相关文章:

javascript - 如果Child组件动态组件,如何将数据从Child传递到Parent

javascript - 将文本数组转换为下拉项?

javascript - 如何将链函数从一个类添加到另一个类?

Javascript:根据单击的按钮运行脚本

接收指向结构的二维数组的指针的 C 函数

c# - 为什么这不会导致事件的无限循环?

javascript - 为什么在使用箭头键时更改功能对我的范围 slider 不起作用?

javascript - 使 PHP 生成的 URL 可在 Javascript 函数中触发

c - 当满足函数条件时 Printf 不工作

c# - Visual Studio 可以为事件自动创建内联本地匿名方法而不是创建具体方法吗?