Echarts 横向柱状图

3 篇文章 0 订阅

实例图片:

横向显示
将xAxis的type设置为value, 将yAxis的type设置为category即可实现横向显示

    placeCharts() {
      let myChart = this.$echarts.init(sportIMg);
      myChart.setOption({
        grid: {
          left: "15",
          containLabel: true,
        },
        xAxis: [
          //x轴数据设置
          {
            type: "value",
            name: "人数",
            min: 0,
            // max: 150,
            //interval: 30, //间隔数
            // splitNumber: 5,
            axisLabel: {
              formatter: "{value} ",
            },
            splitLine: {
              show: false,
            },
            axisLine: {
              //这是y轴文字颜色
              lineStyle: {
                color: "#65C6E7",
              },
            },
          },
        ],
        yAxis: [
          {
            type: "category",
            offset: 0,
            axisLine: {
              //这是x轴文字颜色
              lineStyle: {
                color: "#65C6E7",
              },
            },
            data: this.palceDatas,
            axisPointer: {
              type: "shadow",
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            data: this.palceNum,
            type: "bar",
            barWidth: 22,
            label: {
              normal: {
                show: true,
                // position: "right",
              },
            },
            itemStyle: {
              //通常情况下:
              normal: {
                //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
                color: function (params) {
                  var colorList = [
                    "#855BD7",
                    "#4B6FB8",
                    "#0F6E43",
                    "#B69C2B",
                    "#2588BB",
                    "#BB612D",
                    "#1D9394",
                    "#C24545",
                  ];
                  return colorList[params.dataIndex];
                },
              },
            },
          },
        ],
      });
    },

 

  • 8
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值