渐变色
作者:chrispy
// 多渐变色
itemStyle: {
color: params => {
var colorList = [
['#6c9fda', '#85b3e8'],
['#d26e5d', '#ef9f91'],
['#d89666', '#edbd99'],
['#e9cb70', '#f2e2b2'],
['#91cc63', '#b7e792'],
['#8fd25d', '#baee93'],
['#b25dd2', '#d08ee9'],
['#c6d25d', '#dee790'],
['#d25dcb', '#ed96e8']
]
var index = params.dataIndex
if (params.dataIndex >= colorList.length) {
index = params.dataIndex - colorList.length
}
return new echarts.graphic.LinearGradient(1, 0, 1, 1, [
{offset: 0, color: colorList[index][0]},
{offset: 0.5, color: colorList[index][1]}
])
},
// 单渐变色
itemStyle: {
normal: {
barBorderRadius: [10, 10, 0, 0],
color: color => {
return new echarts.graphic.LinearGradient(1, 0, 1, 1, [{
offset: 0,
color: '#8cbdf1'
}, {
offset: 1,
color: '#408de9'
}])
},
shadowColor: 'rgba(0, 0, 0, 0.4)',
shadowBlur: 10,
shadowOffsetX: 5
}
}