plotly / plotly/plotly.py

Hover tooltip works incorrectly in scatter WebGL

Open
#3,516 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

In the code example below (using the scattergl) when the cursor is rolled over the bubble, the hover tooltip does not appear until the cursor is close to the center of the bubble. The tooltip itself also points to the center of the bubble.

This is different from the expected behavior observed with the regular scatter where the tooltip appears in relation to the boundary of the bubble, rather than its center. And the tooltip points to the boundary as well.

For the Plotly Express px.scatter, one needs to set render_mode='svg' to switch out of WebGL for the correct behaviour.

This results in an incorrect tooltip in WebGL appearing when the cursor is over the larger bubble in an example such as this one:

bubble

import pandas as pd
import plotly.graph_objects as go

df = pd.DataFrame({'x': [1], 'y': [1],'z': [100]})

fig = go.Figure()

fig.add_scattergl(
    x=df['x'],
    y=df['y'],
    marker_size=df['z'],
    mode='markers',
    marker_sizeref=0.01,
    marker_sizemode='area',
    showlegend=True,
    hovertemplate=(
        'x: %{x:.2f}<br>'
        'y: %{y:.2f}<br>'
        '<extra></extra>'
    ),
)

fig.show()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python example with go.Figure.add_scattergl and compare its hover behavior with regular scatter. Trace the WebGL hover handling from the scattergl entry point, using the expected boundary-based tooltip behavior and the render_mode='svg' comparison as references. Done means large bubbles respond across their visible area and the tooltip points to the boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.