echarts图柱状图颜色渐变样式

var myChart = echarts.init(document.getElementById('weixiu'));
        
        var cost = [0.42, 0.53, 0.62, 0.83, 0.96]//柱状图长度
         var dataCost = [420,760,810,760,810]//
         var totalCost = [1, 1, 1, 1, 1]//
         var visits = [420, 530, 602, 853, 963]//数据
         var grade = ['AP', '低压配电室', '风机', '空调', '摄像头']
         var colorList = [
             ['#BC3535','#FF5B79'],
             ['#8D3510','#FFA783'],
             ['#651180','#D099FF'],
             ['#00CCFF','#2953B4'],
             ['#8D104B','#FF83D8'],
             ['#7F610F','#FFE899'],
             ['#00CCFF','#2953B4']
         ];
         var data = {
             title: "设备",
             grade: grade,
             cost: cost,
             totalCost: totalCost,
             visits: visits,
             dataCost:dataCost,
             colorlist1:colorlist1
         };
         var option = {
        //     backgroundColor: '#05274C',
             /* title: {
                 top: '5%',
                 left: 'center',
                 text: data.title + '维修次数统计',
                 textStyle: {
                     align: 'center',
                     color: '#4DCEF8',
                     fontSize: 18
                 }
             }, */
             grid: {
                 left: '240',
                 right: '100'
             },
             xAxis: {
                 show: false,
             },
             yAxis: {
                 type: 'category',
                 axisLabel: {
                     margin: 100,
                     show: true,
                     color: '#4DCEF8',
                     fontSize: 14
                 },
                 axisTick: {
                     show: false,
                 },
                 axisLine: {
                     show: false,
                 },
                 data: data.grade
             },
             series: [{
                 type: 'bar',
                 barGap: '-98%',
                 barWidth: '25%',
                 label: {
                     normal: {
                         show: true,
                         position: 'right',
                         color: '#fff',
                         fontSize: 14,
                         formatter:
                             function(param) {
                                 return data.visits[param.dataIndex] ;
                             },
                     }
                 },
                 itemStyle: {
                     normal: {
                         barBorderRadius: 16,
                         color:  function(params){
                                                        
                            var colorItem = colorList[params.dataIndex];               
                            return new echarts.graphic.LinearGradient(1,0,0,0,[
                                        {
                                            offset:0,
                                            color:colorItem[0]
                                        },
                                        {
                                            offset:1,
                                            color:colorItem[1]
                                        }
                                        ],false);
                            }

      
                     },
                 },
                 max: 1,
                
                 labelLine: {
                     show: true,
                 },
                 z: 2,
                 data: data.cost,
             }]
         }
                            
        
        myChart.setOption(option);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值