Skip to content
Discussion options

You must be logged in to vote

自定义 Tooltip 显示时机

tooltip 开启前提下的默认情况:

  • 行列头点击时显示 tooltip, 单元格文字被省略时悬停显示 tooltip
  • 数值单元格悬停超过 800ms 显示 tooltip

比如想自定义成鼠标悬停行头时显示 tooltip, 可通过自定义交互 详情,
监听行头单元格的 交互事件 S2Event.ROW_CELL_HOVER
. 示例

import { BaseEvent, S2Event } from '@antv/s2';

class RowHoverInteraction extends BaseEvent {
  bindEvents() {
    this.spreadsheet.on(S2Event.ROW_CELL_HOVER, (event) => {
      this.spreadsheet.tooltip.show({
        position: { x: 0, y: 0 },
        content: "..."
      })
    })
  }
}

const s2Options = {
  tooltip: {
    enable: true,
  },
  interaction: {
    customInteractions: [
      {
        key: 'RowHoverInteraction',
        interaction: RowHoverInteraction,
      },
    ],
  }
};

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Alexzjt
Comment options

@Austin-Patrician
Comment options

Answer selected by Austin-Patrician
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants