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/10/18 09:21:43 UTC

[GitHub] [echarts] zogeli100 commented on issue #5522: 饼图 默认显示一个 怎么设置

zogeli100 commented on issue #5522:
URL: https://github.com/apache/echarts/issues/5522#issuecomment-945575205


   ##### 如下配置,默认关闭legend的hover事件
   ##### 然后在series里默认配置一份label的normal样式
   ##### 图表加载完成后默认高亮第一个数据
   ##### 监听图表事件,完成
   ```js
   
   
   option = {
     legend: {
       // data: ['正高级', '高级', '一级', '二级', '三级', '未定级'],
       selectedMode: false
     },
     series: [
       {
         name: '职称比例',
         type: 'pie',
         radius: ['75%', '88%'],
         avoidLabelOverlap: false,
         label: {
           normal: {
             show: false,
             position: 'center', //让label显示在饼图中间
             //formatter: '{c} <br/>{b}', //此处测试结果<br/>不起作用
           },
           emphasis: {
             show: true
           }
         },
         center: ['50%', '50%'],
         labelLine: {
           show: false
         },
         data: [
           {
             name: '正高级',
             value: 2
           },
           {
             name: '高级',
             value: 15
           },
           {
             name: '一级',
             value: 28
           },
           {
             name: '二级',
             value: 37
           },
           {
             name: '三级',
             value: 28
           },
           {
             name: '未定级',
             value: 2
           }
         ]
       }
     ]
   };
   
   setTimeout(function(){
     myChart.dispatchAction({
     type: 'highlight',
     seriesIndex: 0, // series 数据数组第几个
     dataIndex: 0
   });
   myChart.on('mouseover', (e) => {
     if (e.seriesIndex != 0) {
       return;
     }
     //取消默认高亮
     myChart.dispatchAction({
       type: 'downplay',
       seriesIndex: 0,
       dataIndex: this.currentIndex
     });
     myChart.dispatchAction({
       type: 'highlight',
       seriesIndex: e.seriesIndex,
       dataIndex: e.dataIndex
     });
   });
     },0)
   
   ```


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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