echarts 5.0 版本 hideTip 失效, 有类似的方法可以取消提示吗?

image.png

 tooltip: {
  trigger: 'axis',
  triggerOn: 'none',
  axisPointer: {
    type: 'shadow',
    label: {
      show: true
    },
    shadowStyle: {
      color: '#e4e7ed80'
    }
  },
}
myChart.dispatchAction({
  type: 'showTip',
  seriesIndex: _this.seriesIndex,
  dataIndex: _this.dataIndex
  })

myChart.dispatchAction({
  type: 'hideTip'
})
xAxis:[
{
  axisPointer: {
    handle: {
      show: true,
      size: 0
    },
    value: _this.mapArea,
    label: {
      show: false
    }
  },
}
]

datazoom事件 想让如果选中列不在屏幕数据范围内消失选中阴影色,实际不生效

  myChart.on('datazoom', function(params) {
    debugger
    let xAxis = myChart.getModel().option.dataZoom[0]
    console.log(params, xAxis, 'datazoom', '<<<<~~~~~~~~~~~~~~~~~~~')
    const start = xAxis.startValue
    const end = xAxis.endValue
    myChart.dispatchAction({
      type: 'hideTip'
    })

    // if (start < _this.dataIndex || _this.dataIndex > end) {
    //   console.log('~~~~~~~~~~~~~>>>>', 'start')
    //   setTimeout(() => {
    //     myChart.dispatchAction({
    //       type: 'hideTip'
    //     })
    //   }, 0)
    // } else {
    //   setTimeout(() => {
    //     myChart.dispatchAction({
    //       type: 'showTip',
    //       seriesIndex: _this.seriesIndex || 0,
    //       dataIndex: _this.dataIndex || 0
    //     })
    //   }, 1000)
    // }
  })
阅读 3.4k
1 个回答

看了下,题主这个阴影应该是 axisPointer 的,不是 tooltip

所以用 setOtion 即可

myChart.on('datazoom', function(params) {
  myChart.setOption({
    xAxis: {
        axisPointer: {
            handle: {
                show: false,
                size: 0
            },
            value: 1,
            label: {
                show: false
            }
        },
    },
  })
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题