自定义标签和强调标签重叠

Customized label and Emphasis label overlap

我尝试让饼图显示 'customized label',当鼠标触发时更改标签。但除了蓝色数据外,其他所有数据都将与 'emphasis label' 重叠。
'avoidLabelOverlap' 不工作。
有办法吗?
enter image description here enter image description here

这是一个例子

var option = {
  tooltip: {
    trigger: 'item'
  },
  legend: {
    top: '5%',
    left: 'center'
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['40%', '70%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      label: {
        show: true,
        position: 'center',
        formatter:  function (params) {
              var html = 'TEST';
              return html;
            }
      },
      emphasis: {
        label: {
          show: true,
          fontSize: '40',
          fontWeight: 'bold'
        }
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ]
    }
  ]
};

我认为没有办法解决这个问题。

终于找到方法了

使用鼠标事件改变中心的标签。

<!DOCTYPE html>
    <html lang="Zh-TW">
    <head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.2.2/echarts.min.js"></script>
    <meta charset="utf-8">
    </head>
    <body>
    <div id="main" style="width:600px;height:600px;">
    </div>
        
    <script>
var myChart = echarts.init(document.getElementById('main'));
var option = {
    title: {
        text: 'Total',
        textStyle: {
            fontSize: 35,
        },
        x: 'center',
        y: 'center'
        },
    tooltip: {
    trigger: 'item'
    },
    legend: {
    top: '5%',
    left: 'center'
    },
    series: [
        {
        name: 'Testname',
        type: 'pie',
        radius: ['40%', '60%'],
        center: ['50%', '50%'],
        avoidLabelOverlap: true,
        textAlign: 'center',
        label: {
            normal: {
                show: true,
                formatter: function (params) {
                          return params.name+'\n'+params.percent+'%'
                        },
                textStyle: {
                            fontSize: 20
                },
                },
            },
        itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                   },
        data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ]
        },
        {
        name: 'Testname',
        type: 'pie',
        radius: ['40%', '60%'],
        center: ['50%', '50%'],
        avoidLabelOverlap: true,
        textAlign:'center',
        label: {
            normal: {
                show: true,
                position: 'center',
                formatter: '{b}\n{c}',
                align: 'center',
                verticalAlign: 'middle',
                textStyle: {
                            fontSize: 0
                           },
                    },
        emphasis:{
                    show: true,
                    textStyle: {
                        fontSize: 35,
                        fontWeight: 'bold'
                        },
                    formatter: '{b}\n{c}'
                },
        },                        
        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 2
                        },
        data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ]
         },
                   
            ]
};


myChart.setOption(option);

myChart.on('mouseover', { seriesName: 'Testname' }, () => {
    myChart.setOption({
        title: {
                show: false
               }
        })
    })
myChart.on('mouseout', { seriesName: 'Testname' }, () => {
    myChart.setOption({
        title: {
                show: true
               }
        })
    })
</script>
    </body>
    </html>