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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/js/429823.html

猜你在找的JavaScript相关文章