简体   繁体   中英

EchartsJS - Is there a way/workaround to listen to mouse events on the 'legend' component?

I have two graphs side-by-side (pie and line) and I'd like to be able to highlight a line in the line graph upon hovering a legend in the pie graph (without the legend toggling feature).

The mouse events doesn't seem to fire on the legend component.

There's the selectMode option for the legend, but that's not what I want since its toggling the series in the pie chart.

I'm able to catch the legendselectchanged event and "undo" the toggling by setting selected option of the series to true again, but its not ideal and the animation still fires, was unable to disable it.

Any ideas or workarounds?

[ECharts v4] From what I know, legend component internally dispatches 'highlight' and 'downplay' actions, but you can subscribe to those events to.

chart.on('highlight', function (e) {
   // e => {
   // excludeSeriesId: ...
   // name: ...
   // seriesName: ...
   // type: "highlight"
   // }
});
// same for 'downplay'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM