if (item.type === 'pie') {
let i = 0
let value, name, param
let data = []
for (var j = 0; j < xValue.length; j++) {
value = yValue[j]
name = xValue[j]
param = {
'value': value,
'name': name
}
data.push(param)
}
myChart.setOption({
title: {
text: '',
subtext: '',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
orient: 'vertical',
left: 'left',
data: xValue
},
series: [
{
name: item.y,
type: item.type,
radius: '55%',
center: ['50%', '50%'],
data: data,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
normal: {
color: function () {
if (i === that.colorList.length) {
i = 0
}
return that.colorList[i++]
}
}
}
}
]
})
} else {
let i = 0
myChart.setOption({
title: {
text: 'x轴:' + item.x + '' + 'y轴:' + item.y
},
tooltip: {},
legend: {
data: [item.x]
},
xAxis: {
type: 'category',
data: xValue
},
yAxis: {
type: 'value'
},
series: [{
name: '',
type: item.type,
data: yValue,
itemStyle: {
normal: {
color: function () {
if (i === that.colorList.length) {
i = 0
}
return that.colorList[i++]
},
lineStyle: {
color: '#AAAAFF'
}
}
}
}]
})
}
echarts循环自定义颜色
最新推荐文章于 2024-05-30 23:16:00 发布