echarts`柱状图怎么设置达到某个标准之后展示一条过标的线?

730 阅读1分钟

echarts 柱状图怎么设置达到某个标准之后展示一条过标的线? 如图所示中间的红色虚线:

在这里插入图片描述 代码如下:

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
  +   markLine: {
            symbol: ['none', 'none'],
            itemStyle: {
              normal: {
                lineStyle: {
                  type: 'dashed',
                  color: '#F04134',
                },
                label: {
                  show: true,
                  position: 'end',
                  distance: 20,
                  textStyle: {
                    color: '#F04134',
                    fontSize: 30,
                  },

                }
              }
            },
            data: [{
              yAxis: '100',
            }],
            label: {
              normal: {
                show: false
              }
            }
          }
    },
    
  ]
};

这样设置就可以了。