Repository navigation
Conversation
scatter scores a point by its distance to the marker edge, and inside a marker it prefers the smaller one. scattergl and splom used the distance to the marker center only, so the marker drawn on top always won when markers of different sizes overlapped, and a large marker did not hover until the pointer came near its center. scatterpolargl inherits the scattergl result. Share the scatter scoring with scattergl and splom and take each radius from the WebGL marker sizes. Widen the spatial index search box by the largest radius, so large traces find markers whose edge is in range. Fixes plotly#8082
…laps With three size-80 markers on a 400px plot, the pointer 30px from the middle marker was also inside the next one, which correctly won the tie.
The default pointer position is inside two same-size markers of one trace. scatterpolar gives the tie to the point drawn last (point 26), and now scatterpolargl does too, instead of picking the nearer center (point 2).
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR makes
scattergl,scatterpolarglandsplomuse marker size when they pick the hovered point, asscatterdoes.Closes #8082.
Why this is correct
scatterscores a point by its distance to the marker edge. Inside a marker, a smaller marker wins.scatterglandsplommeasured only the distance to the marker center. So the marker drawn on top always won.scattermath intogetAxisDistanceandgetPointDistanceinscatter/hover.js, with no change in behavior.scatterglandsplomnow call them.sizes/sizethatconvertalready computes for the WebGL markers.scatterpolarglgets the fix throughscattergl.Behavior change
The WebGL traces now give the same result as their SVG counterparts. I checked this with real pointer events in Chrome:
[6, 20]at the same pointsplom, sizes[6, 20]scatterpolarglvsscatterpolar, sizes[6, 20]Changes that affect every WebGL plot with markers:
hoverdistanceof the marker edge.spikedistanceand the label order inxhovermode use thescatterscoring.The last item changes five expectations in
scatterpolargl_test.js. The default pointer is 3.7px from point 2 and 5.8px from point 26 of 'Trial 3'. Both markers have a 6px radius.scatterpolarpicks point 26 for the same figure.The hover label still anchors at the marker center in WebGL. I left that out of this PR.
Tests
hover_test.js(hover on points at the same position):scatter,scatterglandsplom;hoverdistance;scattergltrace finds a marker whose center is outside the search box.hover237/237,scattergl48/48,splom51/51,gl2d_click12/12;hover_spikeline45/45,scatterpolargl32/32,gl2d_plot_interact16/16,scattergl_select20/20.select: 115/117. The two failures are the ohlc and candlestick lasso tests, which fail the same way onmain(90f954a) on this machine.npm run lintandnpm run test-syntaxpass.regl-codegen, because no shader code changed.This change was developed with AI assistance (Claude Code). A human reviewed the code and ran the jasmine suites.