如何通过单击图标或符号来更改代码以添加事件警报,并且仅在图例文本上保留默认事件(可见和不可见图表)
plotOptions: {
line: {
events: {
legendItemClick: function () {
alert('I am an alert');
//return false;
// <== returning false will cancel the default action
}
}
,
showInLegend: true
}
}
答案 0 :(得分:2)
比较target
&#39; s:
plotOptions: {
line: {
events: {
legendItemClick: function (event) {
var target = event.browserEvent.target;
if (target.tagName === "text") {
console.log("Text");
} else {
console.log("Marker");
}
}
},
showInLegend: true
}
},