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/10/15 06:07:31 UTC

[GitHub] flyingzl commented on issue #4576: echarts如何禁用最后一个legend的点击事件?

flyingzl commented on issue #4576: echarts如何禁用最后一个legend的点击事件?
URL: https://github.com/apache/incubator-echarts/issues/4576#issuecomment-429719323
 
 
   @VAEAZE 写这样一个函数就行
   
   ```javascript
    /**
     * Echarts中有多图列时,保证Echarts图表至少有一个lenged处于选中状态
     * @parm chart Echarts实例
     */
   const contraintEchartHaveOneVisibleLegend = chart => {
           chart.on('legendselectchanged', function(params) {
               const option = this.getOption()
               const selectedLegends = params.selected
               const keys = Object.keys(selectedLegends)
               const currentLegend = params.name
               if (!keys.filter(key => selectedLegends[key]).length) {
                   option.legend[0].selected[currentLegend] = true
               }
               this.setOption(option)
           })
       }
   }
   ```
   
   

----------------------------------------------------------------
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