Add an event for legend item hovering
You might add mouseover/mouseout events to legend items. This event should provide the index of the legend item.
That gives the developer more control about what to do when hovering legend items and gives him the control to devide whether a tooltip should be shown or the series should be highlighted or whatever.
A common use case might be to show tooltips when hovering legend items --> http://jsfiddle.net/ArmRM/481/
Here’s how to add the events with jQuery:
Jorge Tolentino commented
Tested in Chrome 62.
Sarah Forst commented
This seems almost like a bug to me. For example, in this chart:
I want to bind a behavior to mouse over of both a pie wedge and a legend item. If I hover over the pie, the wedge highlights, the legend item highlights, and my event is triggered. However, if I hover over the legend item, I get the first two behaviors, but no event. This seems inconsistent. I am implementing the jquery solution, but it would be nice if this was built in.
@Patrick, your approach with addressing the legend-items is much better and cleaner.
In the future, Highcharts will revolve more around CSS styling and class names, so this will not change.
Perhaps a slightly better approach that I use is to target the legend item itself instead of just the text. Here is an example:
I wanted to add that the approach you posted requires us to know the classes and element types used to render the chart. If this ever changes, it would force us to have to change as well. Just a thought...
That is exactly what I do, I just thought it would be nice again to have some hover options without having to create an event handler.
I wrote a custom event handler to refresh/hide the tooltip when hovering over a legend. It would be nice if this was natively supported in the apis.
bump bump... first thing i went to try
Ditto for mouseover/mouseout events on axes. Particularly x-axis. I'd very much like to show the total for all the columns in one timeframe tick of the x-axis when the User hovers over the x-axis label text! Similary, would need the index of the tick on the x-axis.
Another possibility might be to add an option like "showTooltipsOnLegendItemHover" handling this. Most probably with a bit more handy name :)