You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2018/07/18 07:13:54 UTC

[GitHub] jeneser edited a comment on issue #8584: legend 中的图例有没有方法做到最少保留一个不被取消选中?

jeneser edited a comment on issue #8584: legend 中的图例有没有方法做到最少保留一个不被取消选中?
URL: https://github.com/apache/incubator-echarts/issues/8584#issuecomment-405833055
 
 
   可以[监听](http://echarts.baidu.com/api.html#events.legendselectchanged) [派发](http://echarts.baidu.com/api.html#action.legend) legend事件,hack一下:
   
   ```
   mychart.on('legendselectchanged', params => {
       let selected = params.selected;
       let count = Object.keys(selected).reduce((acc, val) => {
           return acc + (selected[val] ? 1 : 0);
       }, 0);
   
       if (count === 0) {
           mychart.dispatchAction({
               type: 'legendSelect',
               name: params.name
           });
       }
   });
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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