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

【v5】tooltip share 打开,有时会不共享 #5543

Closed
Deathsteps opened this issue Sep 14, 2023 · 6 comments · Fixed by #5564
Closed

【v5】tooltip share 打开,有时会不共享 #5543

Deathsteps opened this issue Sep 14, 2023 · 6 comments · Fixed by #5564

Comments

@Deathsteps
Copy link
Contributor

问题描述

应该和热区有关(截图看不到光标位置,可自行尝试)

边上一点,就只有柱子的数据
image

中间一点,才能有线的数据
image

期望结果

不管鼠标 hover 在图形何处都应该保持工具提示数据共享

如何重现

官方代码修改

import { Chart } from '@antv/g2';

const data = [
  { time: '10:10', call: 4, waiting: 2, people: 2 },
  { time: '10:15', call: 2, waiting: 6, people: 3 },
  { time: '10:20', call: 13, waiting: 2, people: 5 },
  { time: '10:25', call: 9, waiting: 9, people: 1 },
  { time: '10:30', call: 5, waiting: 2, people: 3 },
  { time: '10:35', call: 8, waiting: 2, people: 1 },
  { time: '10:40', call: 13, waiting: 1, people: 2 },
];

const chart = new Chart({
  container: 'container',
  autoFit: true,
});

chart.data(data);

chart
  .interval()
  .encode('x', 'time')
  .encode('y', 'waiting')
  .axis('y', { title: 'Waiting', titleFill: '#5B8FF9' });

chart
  .line()
  .encode('x', 'time')
  .encode('y', 'people')
  .encode('shape', 'smooth')
  .style('stroke', '#fdae6b')
  .style('lineWidth', 2)
  .scale('y', { independent: true })
  .axis('y', {
    position: 'right',
    grid: null,
    title: 'People',
    titleFill: '#fdae6b',
  });

chart.interaction('tooltip', { "shared": true });

chart.render();

额外信息

  • G2 5.1.2 版本
@pearmini pearmini added the V5 label Sep 14, 2023
@pearmini
Copy link
Member

鼠标不在折线图绘制区域内不会拾取

@Deathsteps
Copy link
Contributor Author

我理解打开 share,应该同 X 轴共享 Tooltip 吧,不然一会儿显示 A,一会儿显示 AB,很奇怪,真的有人这么用图吗?

@pearmini
Copy link
Member

share 这配置我看看

@pearmini
Copy link
Member

看了一下这和 share 没有关系,share 不使用于种 tooltip,这个 #5564 添加了一个 closest 配置解决这个问题。

@pearmini
Copy link
Member

看了一下这和 share 没有关系,share 不使用于种 tooltip,这个 #5564 添加了一个 closest 配置解决这个问题。

经过讨论,这个配置可以去掉。

@Calmio-Y
Copy link

@pearmini 柱状和散点和折线组合,坐标轴不共享的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants