echarts环形图自定义title居中显示

14 篇文章 0 订阅
mounted() {
  this.drawLine()
},
updated(){
  this.drawLine()
},
methods: {
  drawLine(){
    let myChart = echarts.init(document.getElementById('myChart'));
    let dataName = [];
    let total = 0;
    this.list.forEach((res) => {
      dataName.push(res.name);
      total += parseFloat(res.value);
    });
    myChart.setOption({
      title: {
        zlevel: 0,
        text: [
          '{money|¥}'+'{value|' + total + '}',
          '{name|总金额}',
        ].join('\n'),
        top: 'center',
        left: '46%',
        textAlign: 'center',
        textStyle: {
          rich: {
            value: {
              color: '#303133',
              fontSize: 22,
              fontWeight: 'bold',
              lineHeight: 40,
            },
            name: {
              color: '#ccc',
              fontSize: 16,
              lineHeight: 18
            },
            money: {
              color: '#767676',
              fontSize: 16,
              lineHeight: 18
            },
          },
        },
      },
      color:['#83D587','#4DA1FF','#FFA800','#a249e7'],
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      series: [{
        name: '订单数量',
        type: 'pie',
        radius: ['80%', '100%'],
        avoidLabelOverlap: false,
        hoverAnimation: false, // 取消掉环形图鼠标移上去时自动放大
        itemStyle : {   //图形外文字上下显示
          normal : {
            label : {
              show : false
            },
            labelLine : {
              show : false
            }
          },

        },
        emphasis: {
          label: {
            show: false,
            fontSize: '40',
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: this.list
      }]
    });
  },
},

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值