只接收特定格式的数组对象,所以要转化
注意初始化和清除
drawPie(id) {
this.charts = echarts.init(document.getElementById(id))
this.charts.setOption({
color: ['#ccc','#1890ff','#52c41a','#f5222d'], //自定义颜色
series: [
{
name: '访问来源',
type: 'pie',
radius: ['40%', '60%'], //内径外径
label: {
normal: {
show: false
},
emphasis: {
show: true,
formatter: '{c}',
}
},
lableLine: {
normal: {
show: false
},
emphasis: {
show: true,
}
},
data:this.chartData[id]
}
]
})
},