echarts环形饼图

效果示例

在这里插入图片描述

代码汇总

 pieCharts() {
   
      let data = [];
     const providerResult = [
          {
   name: '智诺', value: 23},
          {
   name: '海康', value: 5},
          {
   name: '大华', value: 5},    
          {
   name: '云科', value: 23},
          {
   name: '四信', value: 22},
          {
   name: '九物', value: 22}
              
        ]
      let charts = echarts.init(document.getElementById('manufactureCharts'));
      let color = ['#4f83e6','#009aff','#db8645','#e3737f','#febd09','#4ec09d']
      let option = this.getPieOption(providerResult, color);
      charts.setOption(option, true);
      // 自动hover的方法 需要在index.html中引用 
      //./echarts-auto-tooltip.js 可在网上找相关资源
      
      tools.loopShowTooltip(charts, option, {
   loopSeries: true,interval:5000})

    },
getPieOption(typeDatas, color1) {
   
      let width = window.innerWidth;
      let fontSize1 = 30;
      let fontSize2 = 16;
      let height = 20;
     
      let data = [];
      let color = color1
     
      for (let i = 0; i < typeDatas.length; i++) {
   
        data.push(
          {
   
            value: typeDatas[i].value,
            name: typeDatas[i].name,
            avoidLabelOverlap: false,
            label: {
   
              show: false,
              position: 'center',
              // color: '#ddd',
              formatter: '{numberText|{c}%}\n{textStyle|{b}}',
              rich: {
   
                numberText: {
   
                  color: '#fff',
                  fontSize: fontSize1,
                  fontFamily: 'Avenir, Helvetica, Arial, sans-serif',
                  fontWeight:700
                },
                textStyle: {
   
                  color: color[i],
                  fontSize: fontSize2,
                  fontFamily: 'SourceHanSansSC-Medium',
                  height: height,
                  fontWeight:700
                }
              }
            },
             emphasis: {
   
              label: {
   
                show: true,
                fontWeight: 'bold'
              }
            },
            
            itemStyle: {
   
             
              normal: {
   
                borderWidth: 2,
                // shadowBlur: 5,
                borderColor:  '#181F35',
                // shadowColor: color[i],
                color: color[i],
                // backgroundColor: color[i] '#181F35'
              }
            }
          },
          
        );
      }
      let seriesOption = [
        {
   
          name: '',
          type: 'pie',
          radius: ['55%', '65%'],
          itemStyle: {
   
            borderRadius: 50,
            borderColor: '#181F35',
            borderWidth: 55,
            },
           emphasis: {
   
               disabled: false,
                scale: true,
               scaleSize: 11,
               label : {
   
                 show: true,
                fontSize: '100',
                fontWeight: 'bold'
               }
          },
          data: data
        }
      ];
      let option = {
   
        tooltip: {
   
          show: false,
          trigger: 'item'
        },
        toolbox: {
   
          show: false
        },
        series: seriesOption
      };
      return option;
    },

相关推荐

  1. Vue2 Echarts 3D

    2023-12-07 17:44:02       31 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-07 17:44:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-07 17:44:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-07 17:44:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-07 17:44:02       20 阅读

热门阅读

  1. fastapi实现websocket在线聊天

    2023-12-07 17:44:02       44 阅读
  2. Redis雪崩

    2023-12-07 17:44:02       42 阅读
  3. 【重点】【双指针】42. 接雨水

    2023-12-07 17:44:02       41 阅读
  4. mybatis 实现批量更新的三种方式

    2023-12-07 17:44:02       28 阅读