Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tooltip interaction emit events when body hide #5157

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

pepper-nice
Copy link
Contributor

描述

chart.on('tooltip:show', () => {}) 依赖 tooltip 显示才能调用。
业务层期望使用 tooltip:show 但不使用 G2 tooltip 组件,使用业务层的 tooltip 组件。

chart
  .interval()
  .data([
    { genre: 'Sports', sold: 275 },
    { genre: 'Strategy', sold: 115 },
    { genre: 'Action', sold: 120 },
    { genre: 'Shooter', sold: 350 },
    { genre: 'Other', sold: 150 },
  ])
  .encode('x', 'genre')
  .encode('y', 'sold')
  .encode('color', 'genre')
  .interaction('tooltip', {
    showContent: false,
  });

  chart.on('tooltip:show', ({ data }) => {
    p.innerText = JSON.stringify(data);
  });

  chart.on('tooltip:hide', () => {
    console.log('hide');
  };);

chart.render();
image

src/interaction/tooltip.ts Outdated Show resolved Hide resolved
src/interaction/tooltip.ts Outdated Show resolved Hide resolved
src/interaction/tooltip.ts Outdated Show resolved Hide resolved
@pearmini
Copy link
Member

pearmini commented Jun 5, 2023

我比较好奇,为啥需要这个能力,render 函数不行吗?还是希望 render 能返回当前的数据?

@pepper-nice pepper-nice force-pushed the feat/tooltip-showContent branch 2 times, most recently from 90b1a58 to 937c192 Compare June 6, 2023 02:17
@pepper-nice
Copy link
Contributor Author

我比较好奇,为啥需要这个能力,render 函数不行吗?还是希望 render 能返回当前的数据?

渲染没有走 render 函数,用了 plot.on('tooltip:show', render) 的方式。
因为 render 不够灵活,无法控制锁定/解锁状态,无法在其他交互时渲染调用该 render 函数传入特殊参数。

@pearmini
Copy link
Member

pearmini commented Jun 8, 2023

无法控制锁定/解锁状态

这个是 G2 的 tooltip 应该是需要提供相应的 API 的。

无法在其他交互时渲染调用该 render 函数传入特殊参数。

只要 render 函数的参数提供了对应的数据点,就可以获得特殊的参数?

@pepper-nice pepper-nice force-pushed the feat/tooltip-showContent branch from 937c192 to d5d665e Compare June 26, 2023 05:45
@pepper-nice pepper-nice force-pushed the feat/tooltip-showContent branch from d5d665e to 1eba0a9 Compare June 26, 2023 07:26
@pearmini pearmini changed the title feat: tooltip interaction support showContent params feat: tooltip interaction emit events when body hide Jun 27, 2023
@pearmini pearmini merged commit b8491c3 into v5 Jun 27, 2023
@pearmini pearmini deleted the feat/tooltip-showContent branch June 27, 2023 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants