echarts多柱重叠不累加

主体思路,设计两个x轴,控制重合,实现多柱情况下的堆叠或重叠,上代码:

options: {
  tooltip: {
    trigger: 'axis',
    axisPointer: {            // 坐标轴指示器,坐标轴触发有效
      type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    top: '30%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      axisTick: { //y轴刻度线
        show: false
      },
      axisLine: {
        show: false
      },
    },
    {
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitArea: {
        show: false
      },
      splitLine: {
        show: false
      },
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    },
  ],
  yAxis: [
    {
      type: 'value',
      axisTick: { //y轴刻度线
        show: false
      },
      axisLine: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
          color: '#DCDCDE'
        }
      }
    }
  ],
  series: [
    {
      name: '今年计划',
      type: 'bar',
      xAxisIndex: 1,
      itemStyle: {
        normal: {
          show: true,
          color: '#FEEFB1'
        }
      },
      barWidth: '30%',
      data: [33, 33, 33, 33, 33, 33, 33]
    }, {
      name: '去年计划',
      type: 'bar',
      xAxisIndex: 1,
      barWidth: '30%',
      barGap: '50%', // 设置多柱之间空隙
      itemStyle: {
        normal: {
          show: true,
          color: '#b8e0ab'
        }
      },
      data: [51, 51, 51, 51, 51, 51, 51]
    }, {
      name: '今年完成',
      type: 'bar',
      barWidth: '30%',
      itemStyle: {
        normal: {
          show: true,
          color: '#FCD63D'
        }
      },
      data: [8, 15, 10, 20, 22, 30, 22]
    }, {
      name: '去年完成',
      type: 'bar',
      barWidth: '30%',
      barGap: '50%',
      itemStyle: {
        normal: {
          show: true,
          color: '#79c65f'
        }
      },
      data: [8, 17, 26, 30, 32, 45, 30]
    }
  ]
}

效果图如下:
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值