html
<div id="echart" ref="echart" style="width: 100%;height: 260px;"></div>
配置
initBar() {
let dateline = this.$refs.echart
this.myChart = this.$echarts.init(dateline);
this.myChart.clear();
let option = {
tooltip: {
trigger: 'item'
},
legend: {
bottom: '0',
left: 'center',
icon: "circle", //图例设置为圆形
type: 'scroll', //图例多的情况下可以整行显示 有左右控制键
itemGap: 20, //这个值是用来调图例之间的间距
},
series: [
{
name: 'Access From',
type: 'pie',
radius: ['40%', '70%'],//设置为环形
data: this.alarmAnalyse.data,
label: {
alignTo: 'edge',
formatter: '{name|{b}}\n{time|{c}}',//键名和键值都显示
minMargin: 5,
edgeDistance: 10,
lineHeight: 15,
rich: {
time: {
fontSize: 16,
color: '#1677ee'//修改键值的样式
}
}
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
this.myChart.setOption(option);
},
数据格式
this.alarmAnalyse.data = [
{ name: '压力报警', value: 172 },
{ name: '泵故障报警', value: 79 },
{ name: '水箱报警', value: 39 },
{ name: '泵房报警', value: 43 },
{ name: '变频器故障报警', value: 44 },
{ name: '市政、传感器报警', value: 41 }
]