echarts 饼图 将数据显示在图例的旁边

写之前注意一下this的指向

我是在定义echarts之前定义

let _that = this

在legend中进行formatter

formatter:function(name){
              var index = 0
              var data = ['贷款','存款']
              var datas = data
              var piedata = [_that.profitPIEdata.LXD_LX,_that.profitPIEdata.CK_LX,]
              datas.forEach(function(value,i){
                if(value == name){
                  index = i;
                }
              })
              return name + ":" + piedata[index];
            }

 

你可能感兴趣的:(vue,echarts,js,javascript,echarts,vue)