百度echarts实现横向渐变效果

一、样例一:

效果图:

代码

option = {
    title: {
      text: 'aaa',
      x: "left"
    },
    tooltip: {
        trigger: 'item',
        position:'right',
        /*
        formatter:function(data){
          //console.info('data',data);
          return data.data.value;
        },*/
        formatter:'{c}',
    },
    grid: {
      x: 0,  //左留白
      bottom: '20px',
      containLabel: true
    },
    xAxis: {
        show:false,
        type: 'value',
        splitLine: {
            show: false
        },
    },
    yAxis: {
        type: 'category',
        axisLine: {
            show:false,
            onZero: false,
        },
        axisTick:{//刻度线
          show:false
        },
        axisLabel: {
            formatter: '{value}'
        },
        boundaryGap: true,
        data: ['广州食药监','广州社保局','广州人民政府','广州气象局'],
        
    },
    series: [
      {
        type: 'bar',
        smooth: true,
        barWidth : 6,//柱图宽度
        barCategoryGap: 10,
        data: [
            {name:'广州食药监',value:222},
            {name:'广州社保局',value:222},
            {name:'广州气象局',value:222},
            {name:'广州人民政府',value:222}
        ],
        itemStyle: {
            emphasis: {
                //barBorderRadius: 7
            },
            normal: {
                //barBorderRadius: 7,
                color: new echarts.graphic.LinearGradient(
                    0, 0, 1, 0,
                    [
                        {offset: 0, color: '#CCEEFF'},
                        {offset: 1, color: '#5599FF'}
                    ]
                )
            }
        }
      }
    ]
};

样例二:

效果图:

代码:

option = {
    title: {
      text: 'aaa',
      x: "left"
    },
    tooltip: {
        trigger: 'item',
        position:'right',
        /*
        formatter:function(data){
          //console.info('data',data);
          return data.data.value;
        },*/
        formatter:'{c}',
    },
    grid:{   //绘图区调整
      x:25,  //左留白
      y:30,   //上留白
      x2:25,  //右留白
      y2:0,   //下留白
      containLabel: false
    },
    xAxis: {
        show:false,
        type: 'value',
        splitLine: {
            show: false
        },
    },
    yAxis: {
      show:false,
      type: 'category',
      axisLine: {
        onZero: false,
      },
      boundaryGap: true,
    },
    series: [
      {
        type: 'bar',
        smooth: true,
        barWidth : 6,//柱图宽度
        barCategoryGap: 10,
        data: [
            {name:'广州食药监',value:222},
            {name:'广州社保局',value:222},
            {name:'广州气象局',value:222},
            {name:'广州人民政府',value:222}
        ],
        label: {
          normal: {
            show: true,
            position: [0,-16],//'insideLeft',
            formatter:'{b}',
            textStyle: {
              fontSize: '13',
              //fontWeight: 'bold',
              color:'#727475'
            }
          }
        },
        itemStyle: {
            emphasis: {
                //barBorderRadius: 7
            },
            normal: {
                //barBorderRadius: 7,
                color: new echarts.graphic.LinearGradient(
                    0, 0, 1, 0,
                    [
                        {offset: 0, color: '#CCEEFF'},
                        {offset: 1, color: '#5599FF'}
                    ]
                )
            }
        }
      }
    ]
};

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值