自学内容网 自学内容网

echarts 中添加图片/图标

 

 

let myChart = echarts.init(this.$refs.chartOne); // 注意这里的 ref 引用  
  myChart.setOption({  
    tooltip: {
      trigger: 'item',
      formatter: '{b} : {c}'
     },
     series: [{
       type: 'pie',
       radius: '50%',
       data: this.swjList,
       label: {
         formatter: (params) => {
           if (params.name !== '') {
             let percentl = params.percent === undefined ? 0 : params.percent
               if(Number(percentl) > 15){
                  return params.percent + '%{Sunny|}'
                }else{
                  return `${percentl}%`
                }
              }
              return ''
           },
          rich: {
             cValue: {
                height: 25,
                padding: [0, 10, 0, 30],
                align: 'right'
               },
              Sunny: {
                 height: 15,
                 width: 15,
                 align: 'left',
                 backgroundColor: {
                   image: require('../../../assets/images/warning.png'),
                   repeat: 'no-repeat',
                   repeat: 'no-repeat',
                   position: 'center'

                 }
                },
              }
           },
           emphasis: {
               itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
         }]
       });  
      window.addEventListener('resize', () => {  
         myChart.resize();  
      });  

Echarts —自定义label标签的样式(formatter,rich,添加图标等操作)_echarts label-CSDN博客


原文地址:https://blog.csdn.net/szzlh123456789/article/details/142824961

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!