如果您將trackByArea選項設置爲true,則即使系列位於另一系列的後面,它也會啓用捕獲點擊事件。
plotOptions: {
series: {
trackByArea: true,
events: {
click: function(event) {
alert(this.name);
}
}
}
},
例如:http://jsfiddle.net/83x6L69x/
然而,這將捕獲的事件,甚至當你點擊不完全的點。爲了避免它,你可以檢查,如果點擊事件點的標記內部完成:
plotOptions: {
series: {
trackByArea: true,
point: {
events: {
click: function(e) {
console.log(this)
const group = this.series.group
const x = e.chartX - this.plotX - group.translateX
const y = e.chartY - this.plotY - group.translateY
const d = (x * x + y * y)
const rPlus = this.graphic.states.hover.radiusPlus // it is an additional radius when the point is hovered
const r = this.graphic.radius + (rPlus || 0)
if (x * x + y * y <= r * r) {
alert(this.series.name)
}
}
}
}
}
},
例如:http://jsfiddle.net/dh4zn6h4/