导入Echarts
import * as echarts from 'echarts'
设置径向渐变
const colorArr = [ ['#0BA82C', '#4FF778'],
['#2E72BF', '#23E5E5'],
['#5052EE', '#AB6EE5']
]
series: [
{
itemStyle: {
color: arg => {
let targetColor
if (arg.value >= 300) {
targetColor = colorArr[0]
} else if (arg.value >= 200) {
targetColor = colorArr[1]
} else {
targetColor = colorArr[2]
}
return new echarts.graphic.LinearGradient(0, 1, 0, 0, [ { offset: 0, color: targetColor[0]
},
{
offset: 1,
color: targetColor[1]
}
])
}
}
}
],