score:70
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.
score:11
for me, the legenditemclick event had to be for the series, not the line. e.g.:
plotoptions: {
series: {
events: {
legenditemclick: function(event) {
var visibility = this.visible ? 'visible' : 'hidden';
if (!confirm('the series is currently '+
visibility +'. do you want to change that?')) {
return false;
}
}
}
}
},
example from highcharts: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-events-legenditemclick/
Source: stackoverflow.com
Related Query
- How to modify highcharts legend item click event?
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- highcharts how to catch and insert logic in click reset zoom button event
- How to pass custom data into Highcharts graph click event
- How to trigger a legend click in HighCharts with jQuery?
- How to attach click event function in Highcharts
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- How to add series after click event in HighCharts
- How do I attach a click event handler to the whole HighCharts Gauge control?
- How can I make React Native in Android aware of a click event in a tooltip in a Highcharts chart?
- Highcharts - How can I get the nearest point on click event
- Toggling legend text click event in highcharts
- HighCharts : How to add click event on colorAxis in heatmap
- How do I catch a click event on a polygon in HighCharts without having the tooltip popping up
- Click on Highcharts pie rendering border although legend item click is disabled
- How to trigger legend click event on outside when using Highchart and no using JQuery
- How can I unclick an event in highcharts on the second click
- Highcharts Legend event click to get data
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- Highcharts : How to perform an action on Pie chart's legend click ?
- Highcharts - How to Make the legend item width half of the contianer?
- Highcharts how to add treemap upon click event on line chart?
- Edit click event on Highcharts Legend
- How to call EventEmitter on click event with HighCharts
- How to manually trigger the afterSetExtremes event from a series click event in HighCharts
- How to fire click event in moxie highcharts
- How to disable legend click to stop pie slice from disappearing in Highcharts?
- How do I add an event listener to a Highcharts object *AFTER* I've created it
- Highcharts - How to programmatically toggle legend items and determine which items are selected
- Highcharts - How to display legend symbol inside the tooltip
More Query from same tag
- Highcharts setting the colour of columns in each month period
- Highchart dual layer donut slide both the inner and outer donuts together
- Display maximum value of a highcharts stacked column on the bottom
- how to select a button in highcharts-range selector row and click
- how to add xAxis.tick dynamically
- Why does opening a CSV file in Excel break my Highcharts chart?
- Highchart line chart tooltip issues with large dataset
- Export Multiple Highcharts to Multi-page PDF
- highcharts stackLabels updating issue
- ASP.NET Controller return variable View access
- highchart tooltip with multiple additional data in tooltip?
- Highchart: in bar chart, how to increment a bar according to data?
- How to make split grouped column bar chart in highcharts with percentage?
- Highstocks displays too many ticks
- Highcharts - Replace nulls with 0
- Getting javascript undefined TypeError
- Highcharts, trying to regulate maximum height of chart columns NOT including Axes
- Plot a a json chart with HighCharts & Vue.js
- How do you get Highcharts to scale up image contents rather than add more details?
- HighCharts: Basic line chart doesn't show first label on the X-axis
- Highcharts: how to export several charts from the browser?
- Display the Plotted value on x axis using highcharts
- how to display highchart graphic with data defined in html table?
- Scrape data from a highchart using selenium
- How to display datapoint labels / values in Rickshaw graph visualizations?
- Gradient on sankey diagram
- Extra Labels on Stacked Column After Label Toggle and Resize
- How to give box shadow for rect in highcharts?
- How to display values on line stacked columns on highcharts
- Highcharts how to only plot if x axis is having value greater than 0?