antvis/G2

changeData更新数据tooltip会消失 #5883

demolhy posted onGitHub

问题描述

需要重新移动鼠标才会显示,而且偶尔会跑到左下角去再回来

chart
.line()
.axis('x', {
  label: null,
  title: null,
  tickFilter: false,
  tick: false,
  line: false,
  grid: true,
  gridFilter: (_: any, index: number) => {
    return index % 10 === 0;
  },
})
.axis('y', {
  labelFormatter: (val: string) => {
    return `${val}%`;
  },
  line: true,
  lineExtension: [0, 0],
  lineStroke: '#EEEEEE',
})
.scale('y', { zero: true, type: 'linear', domain: [0, 100] })
.encode('x', 'time')
.encode('y', 'value')
.encode('shape', 'smooth')
.animate(false)
.encode('color', 'group')
.scale('color', {
  range: ['#00baa4', '#0090f8', '#f97316'],
  independent: true,
})
.interaction('tooltip', {
  render: (_: unknown, { title, items }: never) => tooltipRender(title, items),
})
.tooltip(
  (
    d, // 每一个数据项
  ) => {
    return {
      value: d.value + '%',
    };
  },
)
.style('strokeWidth', 1)

重现链接

No response

重现步骤

No response

预期行为

实时显示更新的tooltip数据,tooltip不消失

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

https://github.com/antvis/G2/assets/39995045/bda5caaf-671e-46fb-a2c2-5868645c3304

补充说明(可选)

No response


这是符合预期的,因为每次渲染都会销毁 tooltip。如果希望模拟不消失的效果,可以再每次调用 chart.changeData 之后,调用 chart.emit('tooltip', {}),具体参考文档

posted by pearmini over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests