You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/03/29 07:30:38 UTC

[GitHub] [echarts] 14glwu edited a comment on issue #13828: 页面内多图表实例联动场景下,如何关闭个别属性联动,例如关闭tooltip联动,其他行为联动保持正常

14glwu edited a comment on issue #13828:
URL: https://github.com/apache/echarts/issues/13828#issuecomment-809141838


   > > > 讲一下我最后的解决办法,仅供参考,非必要不建议改源码
   > > > 图表联动,本质是某一图表触发action时,遍历当前group内的图表,dispatch对应的action,
   > > > 解决的思路为,在遍历group,触发action前,判断`eventType`是否需要联动,不需要则不触发action
   > > > 解决方法:
   > > > 
   > > > * 图表配置`options`内增加要排除的联动属性 `disabledConnectEventTypes`, `string []`
   > > > * 在这个方法内,判断如果是不需要联动的属性,不触发action
   > > > 
   > > > ```js
   > > >     each(eventActionMap, function (actionType, eventType) {
   > > >       chart._messageCenter.on(eventType, function (event) {
   > > >         var options = chart._model.option;
   > > >         // 过滤不需要联动的actionType
   > > >         var disabledConnectEventTypes = _.get(chart, '_model.option.customConf.disabledConnectEventTypes', []);
   > > >         if (disabledConnectEventTypes.includes(eventType)) return
   > > >         // 原有逻辑 ....
   > > >       });
   > > >     });
   > > > ```
   > > 
   > > 
   > > 你这个是修改源码了么
   > 
   > 是的,不建议改源码,我们是项目里有多处需要改的,就一并改了
   
   我看了下echarts源码找到了一种新的解决办法,就是使用batch方式,这样可以使用到escapeConnect属性
   ![image](https://user-images.githubusercontent.com/26249572/112801390-6b591000-90a3-11eb-809d-4391dbaec9e7.png)
   ``` 
   chartInstance.dispatchAction({
     type: 'legendUnSelect',
     escapeConnect: true,
     batch: [
       {
         name: key,
         selected: legendsSelected,
       },
     ],
   });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org