echarts柱状图柱体渐变色
时间: 2023-12-08 13:39:37 浏览: 41
以下是设置echarts柱状图柱体渐变色的示例代码:
```javascript
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'bar',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#83bff6'},
{offset: 0.5, color: '#188df0'},
{offset: 1, color: '#188df0'}
]
)
}
}
}]
};
```
在上述代码中,我们使用了 `echarts.graphic.LinearGradient` 来设置柱体的渐变色。其中,`offset` 表示渐变的位置,`color` 表示渐变的颜色。你可以根据自己的需求来调整渐变的位置和颜色。