echarts的柱子变成渐变色

找到series定义图片的位置 加上itemStyle里面的代码

series: [
           {
    
    
                 name: '2011',
                 type: 'bar',
                 itemStyle:{
    
    
                     normal:{
    
    
                         color:new $echarts.graphic.LinearGradient(
                             0 0, 0, 1, [{
    
    //代表渐变色从正上方开始
                                     offset: 0, //offset范围是0~1,用于表示位置,0是指0%处的颜色
                                     color: 'rgba(220, 160, 14, 1)'
                                 }, //柱图渐变色
                                 {
    
    
                                     offset: 1, //指100%处的颜色
                                     color: 'rgba(220, 160, 14, 0.5)'
                                 }]
                         ),
                     }
                 }
             }
 ]

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/124735255