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博客