Echarts 带预警线的柱状图

Echarts 带预警线的柱状图


效果
在这里插入图片描述

JS代码

      dataArry: ['33'],
      dataCount: [66],
      option: {
        grid: {
          show: 'true',
          borderWidth: '0',
          // height: '100%',
          width: '100%',
          x: '0'
        },
        tooltip: {
          show: false,
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: '{b0}: {c0}'
        },
        // 背景色
        backgroundColor: '#92929A',
        xAxis: {
          // 是否显示x轴
          show: false,
          type: 'value',
          splitLine: {
            show: true
          }
        },
        yAxis: {
          type: 'category',
          // 让y轴数据逆向
          inverse: true,
          axisLabel: {
            show: true,
            formatter: function (value, index) {
              return ['{title|' + value + '} '].join('\n')
            },
            // 定义富文本标签
            rich: {
              title: {
                color: '#fff',
                fontWeight: 'lighter'
              }
            }
          },
          // 横向的线
          splitLine: { show: false },
          // y 轴的端点
          axisTick: { show: false },
          // y轴的线
          axisLine: { show: false },
          data: this.dataArry
        },
        series: [
          {
            name: '数据内框',
            type: 'bar',
            itemStyle: {
              color: '#2EFE3E'
            },
            barWidth: 30,
            // 实际数量
            data: [70]
          },
          {
            name: '外框',
            type: 'bar',
            markLine: {
              symbol: 'none',
              silent: true,
              data: [
                {
                  coord: ['33', 66],
                  silent: false,
                  lineStyle: {
                    type: 'solid',
                    width: 6,
                    color: 'yellow'
                  },
                  // 黄色警戒值
                  xAxis: 85
                },
                {
                  coord: ['33', 3],
                  silent: false,
                  lineStyle: {
                    type: 'solid',
                    width: 6,
                    color: 'red'
                  },
                  // 红色警戒值
                  xAxis: 90
                }
              ],
              lineStyle: {
                show: true,
                color: '#808C94',
                type: 'dashed'
              }
            },
            itemStyle: {
              // barBorderRadius: 0,
              // rgba设置透明度0.14
              color: 'rgba(255, 255, 255, 0.14)'
            },
            barGap: '-100%',
            z: 0,
            barWidth: 30,
            data: [100]
          }
        ]
      }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值