简体   繁体   English

EchartsJS - 有没有办法/解决方法来监听“图例”组件上的鼠标事件?

[英]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.图例有selectMode选项,但这不是我想要的,因为它会切换饼图中的系列。

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.我能够捕获legendselectchanged事件并通过再次将系列的选定选项设置为 true 来“撤消”切换,但它并不理想并且动画仍然触发,无法禁用它。

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. [ECharts v4] 据我所知,legend 组件会在内部调度 'highlight' 和 'downplay' 动作,但你可以订阅这些事件。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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