我想知道如何在使用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');
}
}
}