echarts 自定义标识线

写了个例子 记录一下      复制到https://echarts.apache.org/examples/zh/editor.html?c=bar-simple 中 可以看效果

option = {
  title: {
    text: '世界人口总量',
    subtext: '数据来自网络'
  },
  legend: {
    data: ['2011年', '2012年']
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01]
  },
  yAxis: [
    {
      type: 'category',
      data: ['西瓜', '草莓', '哈密瓜', '车厘子', '橘子', '小可爱']
    },
    {
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false
      },
      axisPointer: {
        type: 'none'
      },
      splitArea: {
        show: false
      },
      splitLine: {
        show: false
      },
      data: ['西瓜', '草莓', '哈密瓜', '车厘子', '橘子', '小可爱']
    }
  ],
  series: [
    {
      name: '2011年',
      type: 'bar',
      data: [18, 23, 29, 10, 34, 63],
      barWidth : 40,
    },
   
    {
      name: '123',
      stack: 'breakevenEleGroup' /*数据组,需要设置才能将两个bar堆积在一起*/,
      type: 'bar',
      yAxisIndex: 1,
      itemStyle: {
        normal: {
          color: 'rgba(0,0,0,0)' ,/*设置bar为隐藏,撑起下面横线*/
        }
      },
      data: [12, 17, 20, 3, 33, 118]
    },
    {
      /*这个bar是横线的显示*/
      name: '123',
      stack: 'breakevenEleGroup' /*数据组,需要设置才能将两个bar堆积在一起*/,
      type: 'bar',
      yAxisIndex: 1,
       barWidth : 50,
      itemStyle: {
        normal: {
          color: 'red'
        }
      },
      data: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2]
    },
    
  ]
};

 

posted @ 2021-12-14 14:38  啾啾啾啾一口  阅读(1003)  评论(0编辑  收藏  举报