Settings and activity
1 result found
-
45 votes
Here’s how to add the events with jQuery:
http://jsfiddle.net/highcharts/5V33F/An error occurred while saving the comment
1 result found
Here’s how to add the events with jQuery:
http://jsfiddle.net/highcharts/5V33F/
Based on @Jorge solution I created a universal function that will work in pie or bar charts:
```
const legendItemHover = (event) => {
const { chart: legendHoveredChart } = event.target;
const { legend, tooltip } = legendHoveredChart;
for (const item of legend.allItems) {
item.legendItem.on('mouseover', () => {
const data = item?.series?.data[item.index] || item.data[0];
tooltip.refresh(data);
legend.allItems.forEach((itm) => itm.setState('inactive'));
item.setState('hover');
}).on('mouseout', () => {
tooltip.hide();
legend.allItems.forEach((itm) => itm.setState('normal'));
});
}
};
```
pie chart plotOptions:
```
{
pie: {
events: {
afterAnimate(event) {
legendItemHover(event);
},
},
}
}
```
bar chart plotOptions:
```
{
series: {
events: {
afterAnimate(event) {
legendItemHover(event);
},
},
}
}
```