echarts:实现鼠标hover 坐标轴也跟随高亮

 

遇到的一个很头疼的问题,要求坐标轴也跟随高亮,但是echarts没有现有的设定可以做出来,就想了一个偏方。记录一下,代码如下。

option = {
    tooltip: {
    },
    legend: {
        data: ['收入']
    },
    grid: [{
        left: '40',
        right: '4%',
        bottom: '3%',
        containLabel: false,
        tooltip: {
          show: true,
          trigger:'item',
        }
    },
    {
        left: '0',
        right: '4%',
        bottom: '3%',
        containLabel: false,
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
            }
        },
    }],
    xAxis: [
        {
            type: 'value',
            gridIndex: 0,
        },
        {
            type: 'value',
            gridIndex: 1,
        }
    ],
    yAxis: [
        {
            type: 'category',
            gridIndex: 0,
            axisTick: {
                show: false
            },
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        },
        {
            show:false,
            gridIndex: 1,
            type: 'category',
            axisTick: {
                show: false
            },
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        }
    ],
    series: [
        
        {
            name: '收入',
            type: 'bar',
            stack: '总量',
            label: {
                show: true,
                position: 'left'
            },
            data: [-120, -132, -101, -134, -190, -230, -210]
        }
    ]
};

 

相关文章:

  • 2021-09-17
  • 2021-10-01
  • 2021-09-11
  • 2021-10-16
  • 2021-11-07
  • 2021-11-16
  • 2021-09-21
猜你喜欢
  • 2021-05-08
  • 2021-10-02
  • 2021-09-01
  • 2018-02-11
  • 2021-11-18
  • 2021-12-30
  • 2021-11-12
  • 2021-11-12
相关资源
相似解决方案