Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  160] [ 5]  / answers: 1 / hits: 50953  / 12 Years ago, tue, may 15, 2012, 12:00:00

I need to modify click event on highcharts legend items. Highcharts demo http://www.highcharts.com/demo/line-basic . I want for example: first action will be some alert and second action will be action by default(clean Tokyo line from chart). Thanks. Sorry if question not clean.


More From » jquery

 Answers
40

You have to use the legendItemClick callback like the following code



plotOptions: {
line: {

events: {
legendItemClick: function () {
alert('I am an alert');
//return false;
// <== returning false will cancel the default action
}
}
,
showInLegend: true
}
}


Here is working fiddle which shows alert when you click on legends like on Tokyo and then hide Tokyo line.



See also the plotOptions documentation for the event in question. Where you need to place this may differ depending on what chart type you are using.


[#85568] Monday, May 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
paola

Total Points: 675
Total Questions: 115
Total Answers: 95

Location: Laos
Member since Tue, Jul 7, 2020
4 Years ago
;