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(ui): Create and use element id for ECharts when using tooltip.appendToBody #88735

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Apr 3, 2025

ECharts has a tooltip option (appendToBody) to append the tooltip to document.body. This is useful when the charts has a parent container that has e.g. overflow: hidden so that the tooltip does not get cutoff. However we have a custom tooltip positioning function that requires a element id to get a reference of the chart (or its container) to properly position the tooltip. If we use appendToBody without an id, the tooltip does not get displayed near the mouse cursor and instead it's confined within the bounds of the chart.

Before

The crosshairs is where the mouse is (above series both both screenshots)
image
Here the tooltip is not near the series or the mouse
image

After

Notice the tooltips are near the crosshairs
image
image

…ppendToBody`

ECharts has a tooltip option (`appendToBody`) to append the tooltip to `document.body`. This is useful when the charts has a parent container that has e.g. `overflow: hidden` so that the tooltip does not get cutoff. However we have a [custom tooltip positioning function](https://github.com/getsentry/sentry/blob/master/static/app/components/charts/components/tooltip.tsx#L403) that requires a element id to get a reference of the chart (or its container) to properly position the tooltip. If we use `appendToBody` without an `id`, the tooltip does not get displayed near the mouse cursor.
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 3, 2025
@billyvg
Copy link
Member Author

billyvg commented Apr 3, 2025

This also goes ahead and uses appendToBody to fix tooltips getting cutoff in the Releases drawer.

@billyvg billyvg marked this pull request as ready for review April 3, 2025 20:40
@billyvg billyvg requested review from a team as code owners April 3, 2025 20:40
@billyvg billyvg requested a review from a team April 3, 2025 20:40
@billyvg billyvg merged commit ebfde33 into master Apr 4, 2025
46 checks passed
@billyvg billyvg deleted the billy/replay-16-releases-list-drawer-chart-tooltips-are-cut-off-in-the-top-issue-details branch April 4, 2025 14:29
andrewshie-sentry pushed a commit that referenced this pull request Apr 8, 2025
…ppendToBody` (#88735)

ECharts has a tooltip option (`appendToBody`) to append the tooltip to
`document.body`. This is useful when the charts has a parent container
that has e.g. `overflow: hidden` so that the tooltip does not get
cutoff. However we have a [custom tooltip positioning
function](https://github.com/getsentry/sentry/blob/master/static/app/components/charts/components/tooltip.tsx#L403)
that requires a element id to get a reference of the chart (or its
container) to properly position the tooltip. If we use `appendToBody`
without an `id`, the tooltip does not get displayed near the mouse
cursor and instead it's confined within the bounds of the chart.

### Before
The crosshairs is where the mouse is (above series both both
screenshots)

![image](https://github.com/user-attachments/assets/ab34d439-ee7b-4472-9810-11e4946c13bd)
Here the tooltip is not near the series or the mouse

![image](https://github.com/user-attachments/assets/a51e41c6-c55b-4d28-8984-e0cdd169b96c)


### After
Notice the tooltips are near the crosshairs

![image](https://github.com/user-attachments/assets/82ac66ab-f894-4900-a606-2ca3dc524be9)

![image](https://github.com/user-attachments/assets/585aeb0b-fb1c-4fec-ab12-1d129f63909c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants