Reputation: 25
how to can change the code to add the event alert just by clicking the icon or symbol and remains the default event (visible and invisible chart ) just on the text of legend
plotOptions: {
line: {
events: {
legendItemClick: function () {
alert('I am an alert');
//return false;
// <== returning false will cancel the default action
}
}
,
showInLegend: true
}
}
Upvotes: 0
Views: 345
Reputation: 45079
Compare target
'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
}
},
Demo: http://jsfiddle.net/LDMAQ/412/
Upvotes: 2