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

Facet - Tooltip is active only for last mark. [SOLVED] #5908

Closed
JonasJonny opened this issue Dec 7, 2023 · 2 comments
Closed

Facet - Tooltip is active only for last mark. [SOLVED] #5908

JonasJonny opened this issue Dec 7, 2023 · 2 comments

Comments

@JonasJonny
Copy link

问题描述

If you add more marks to the chart, only last one have active Tooltip.

重现链接

https://g2.antv.antgroup.com/en/examples/composition/facet#rect-row

重现步骤

  1. Unchanged link example with "facetRect.point()" (First mark) - Tooltip is working.
  2. We can add second mark
// First mark
facetRect
  .point()
  .encode('x', 'x')
  .encode('y', 'y');

// Second mark
facetRect
  .interval()
  .encode('x', 'x')
  .encode('y', 'series');
  1. Tooltip is working only for interval "Second mark". Nothing shown for point "First mark" (Worked alone 1., Before 2.).
  2. If we remove ".attr('inset', 10)" then points partly outside of facetRect have Tooltip.

image

预期行为

No response

平台

No response

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@JonasJonny JonasJonny changed the title BUG: Tooltip is active only for last mark. BUG: Facet - Tooltip is active only for last mark. Dec 7, 2023
@pearmini
Copy link
Member

pearmini commented Dec 8, 2023

That is because point and interval are rendered into two layers, one will overlap the other one. The right way is to wrap point and interval into a single view:

const chart = new Chart({
  container: 'container',
  width: 928,
  height: 320,
  paddingLeft: 60,
  paddingBottom: 60,
});

const facetRect = chart
  .facetRect()
  .data({
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/anscombe.json',
  })
  .encode('x', 'series');

const view = facetRect.view();

view
  .point()
  .attr('inset', 10)
  .encode('x', 'x')
  .encode('y', 'y')
  .style('stroke', '#000');

view.interval().encode('x', 'x').encode('y', 'series').style('stroke', '#000');

chart.render();

@JonasJonny JonasJonny changed the title BUG: Facet - Tooltip is active only for last mark. Facet - Tooltip is active only for last mark. [SOLVED] Dec 8, 2023
@JonasJonny
Copy link
Author

Thank you @pearmini.
I started from https://g2.antv.antgroup.com/en/examples/composition/facet/#rect.
It was not clear to me that "gray points" are "disabled" automatically on purpose and not manually via options.
Now I can see the workflow.

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

No branches or pull requests

2 participants