有时候接口数据返回的很多条并且数据都是0,就会产生数据堆积重叠的问题。废话不多说直接上代码。直接在series里面放入此代码即可。

series: [{

     // minAngle: 1    //有时候也可以特殊处理一下数据给个值也可以实现不推荐

          label: {

            // eslint-disable-next-line no-tabs

            align: 'left',

            normal: {

              lineHeight: 30,

              textStyle: { fontFamily: 'Microsoft Yahei' },

              formatter(v :any) {

                let text = Math.round(v.percent) + '%' + '' + v.name

                if (text.length <= 8) {

                  return text

                } else if (text.length > 8 && text.length <= 16) {

                  // eslint-disable-next-line no-return-assign

                  return text = `${text.slice(0, 8)}\n${text.slice(8)}`

                } else if (text.length > 16 && text.length <= 24) {

                  // eslint-disable-next-line no-return-assign

                  return text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(16)}`

                } else if (text.length > 24 && text.length <= 30) {

                  // eslint-disable-next-line no-return-assign

                  return text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(16, 24)}\n${text.slice(24)}`

                } else if (text.length > 30) {

                  // eslint-disable-next-line no-return-assign

                  return text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(16, 24)}\n${text.slice(24, 30)}\n${text.slice(30)}`

                }

              }

            }

          }

        }]

Logo

更多推荐