GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Pick the trace drawn last on a hover tie in scattergl and splom by camdecoster · Pull Request #8079 · plotly/plotly.js

Conversation

@camdecoster

@camdecoster camdecoster commented Sep 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Updates scattergl, splom logic to match scatter when a distance tie occurs during hover over a point.

Closes #8077.

Changes

  • Update scatter, splom hover check
  • Add tests
  • Update existing tests

Testing

  • Be on main
  • Open Plotly devtools and run the following snippet in the browser devtools console:
const gd = Tabs.fresh();
Plotly.newPlot(gd, {
    data: [
        { type: 'scattergl', name: 'A', mode: 'markers', marker: { size: 20, color: '#1f77b4' }, x: [0, 1, 2], y: [1, 0, 1] },
        { type: 'scattergl', name: 'B', mode: 'markers', marker: { size: 20, color: '#ff7f0e' }, x: [0, 1, 2], y: [2, 0, 2] }
    ],
    layout: {
        title: { text: 'scattergl: hover the shared point at (1, 0)' },
        width: 500,
        height: 400,
        hovermode: 'closest',
        xaxis: { range: [-0.5, 2.5] },
        yaxis: { range: [-0.5, 2.5] }
    }
});
  • Note that A shows up when hovering over the shared point
  • Switch to this branch
  • Run the snippet again
  • Note that B shows up now

Notes

  • This issue arose due to different tie breaking logic in scatter vs scattergl
  • There's an additional difference between the two methods, even with this change: scatter considers the size of the marker when determining the tie break but scattergl and splom don't
  • This means that on scatter, a marker that's beneath another but has a smaller radius can win the tie break. This is intentional so that users can still get feedback on the smaller marker when it's covered up. Try running this snippet to see what I'm talking about:
const gd = Tabs.fresh();
Plotly.newPlot(gd, {
    data: [
        { type: 'scatter', name: 'A', mode: 'markers', marker: { size: 5, color: '#1f77b4' }, x: [0, 1, 2], y: [1, 0, 1] },
        { type: 'scatter', name: 'B', mode: 'markers', marker: { size: 20, color: '#ff7f0e' }, x: [0, 1, 2], y: [2, 0, 2] }
    ],
    layout: {
        title: { text: 'scatter: hover the shared point at (1, 0)' },
        width: 500,
        height: 400,
        hovermode: 'closest',
        xaxis: { range: [-0.5, 2.5] },
        yaxis: { range: [-0.5, 2.5] }
    }
});
  • For now, scattergl and splom don't consider the radius. I deemed that to be out of scope for this PR, so I'll add a follow up issue to take care of it later.
  • This update required me to flip a loop for the scattergl hover logic when hovermode is something other than "x". In fix for ScatterGL hover and click events give the 'top' point instead of the 'bottom' point #3924, the loop was changed to run backward so that the highest index (the first) would win in the tie break. Due to the logic change, that no longer happened and tests started failing. Making the loop run forward fixes the issue while also maintaining the previous behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
camdecoster added 5 commits September 24, 2026 20:12
@camdecoster
fix: Pick the trace drawn last on a hover tie in scattergl and splom
f269b7a
@camdecoster
Add tests
871402b
@camdecoster
Add draftlog
e17e5a1
@camdecoster
Run the scattergl hover loop forward in the else branch
ced1cfe
@camdecoster
Update tests per behavior change
54c5db6
@camdecoster
camdecoster marked this pull request as ready for review September 25, 2026 17:31
@camdecoster camdecoster assigned T4rk1n Sep 28, 2026
T4rk1n
T4rk1n approved these changes Sep 29, 2026
View reviewed changes
@camdecoster
camdecoster merged commit 62d7214 into main Sep 29, 2026
87 of 88 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@camdecoster
camdecoster deleted the cam/8077/hover-tie-scattergl branch September 29, 2026 20:01
@Lexachoc Lexachoc mentioned this pull request Oct 9, 2026
Hover label order for overlapping points is backwards when using WebGL #4999
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@T4rk1n T4rk1n T4rk1n approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@T4rk1n T4rk1n

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG]: scatter and scattergl show different hover labels for overlapping data points

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@camdecoster @T4rk1n
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.