我想知道如何在使用 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');
}
}
}
关于javascript - 在使用 highcharts 库制作的图表上添加 onclick 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19245781/