echarts 横向柱状图

<div id="mainchartnewed"></div> 

var mainchartnewed = document.getElementById('mainchartnewed');

  var myChartnewed = echarts.init(mainchartnewed);

  var optionnewed;

  optionnewed = {

      grid: {

        left: "27",

        top: "1",

        containLabel: true,

      },

      xAxis: {

        show: false

      },

      yAxis: [{

        type: "category",

        offset: 0,

        barWidth: 10,

        axisLine: {

          show: false,

        },

        data: ['三仁鑫族乡民宿入住优惠', '濂竹乡民宿入住、用餐优惠', '龙洋乡农家乐入住、停车优惠', '按口乡神龙谷景区优惠', '大镇景区、入住、用餐优惠', '金竹镇农家乐入住优惠'],

        axisLabel: { //y轴文字的配置

          textStyle: {

            fontSize: '11',

            color: "#fff", //Y轴内容文字颜色

          },

        },

        axisTick: {

          show: false,

        },

      }, ],

      series: [{

        data: [666, 566, 506, 450, 410, 400],

        type: "bar",

        // barWidth: 22,

        barWidth: 10,

        label: {

          normal: {

            show: true,

            position: "right",

          },

        },

        itemStyle: {

          //通常情况下:

          normal: {

            barBorderRadius: 8,

            //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组

            color: function (params) {

              var colorList = [

                ['#072643', '#48b3db'],

                ['#072643', '#48b3db'],

                ['#072643', '#48b3db'],

                ['#072643', '#48b3db'],

                ['#072643', '#48b3db'],

              ];

              var index = params.dataIndex;

              if (params.dataIndex >= colorList.length) {

                index = params.dataIndex - colorList.length;

              }

              return new echarts.graphic.LinearGradient(0, 0, 1, 0,

                [{

                    offset: 0,

                    color: colorList[index][0]

                  },

                  {

                    offset: 1,

                    color: colorList[index][1]

                  }

                ]);

            },

            label: {

              textStyle: { //数值样式

                color: '#6ec8f1',

                fontSize: 11

              }

            }

          },

        },

      }, ],

    },

    optionnewed && myChartnewed.setOption(optionnewed);

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值