Repository navigation
Add cliponaxis to scattergl - #8222
Open
benjibunbun wants to merge 2 commits into
Open
benjibunbun wants to merge 2 commits into
benjibunbun wants to merge 2 commits into
Conversation
`scatter` has `cliponaxis`, but `scattergl` always clips markers at the plot area, so a marker on an axis shows only in part. If `cliponaxis` is `false`, the marker layers now get a larger viewport and range, so these markers show in full. Lines, fills, error bars and text stay clipped.
This branch has not been deployed
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.
Closes #8074.
This adds
cliponaxistoscatterglso markers on the edge of the plot area can show in full like they already can forscatter. The default is stilltrue. So nothing changes unless a trace setscliponaxis: false.regl-scatter2d uses the viewport as its scissor box, which means the only way to let markers draw past the axes is to give them a bigger viewport. For a
cliponaxis: falsetrace the marker layers (scatter2dandselect2d) get a viewport that is larger by the biggest marker radius on each side. I round that up to whole device pixels because regl truncates the viewport to whole pixels anyway. The range grows by the same amount in data units so the markers stay in the same place on screen.convertMarkerStylealready loops over the sizes and line widths so now it also keeps the largest of each.calcuses those and theselected/unselectedsizes to work out the pad once per trace. No extra pass over the data. I also changedplotto callscene.updateinstead of updating each layer by itself. That way the first draw and pan/zoom go through the same code and can't end up with different padding.Lines, fills and error bars stay clipped like they do for
scatter. Text stays clipped too, and that part is different fromscatter.scattergldraws text with gl-text, which has its own viewport, and how far a label reaches depends on its text. So I kept this to markers, which is what the issue is about.There are two more differences from
scatterthat I didn't try to fix here:scatterhides those points. Fixing it needs either a filter over the points on every pan frame or a change to the regl-scatter2d shader.xaxis.layeris. That's the same thing as [BUG]:axis.layer/axis.zerolinelayer:'above traces'do not render abovescattergltraces #8075.I didn't add it to
scatterpolargl. Itsattributes.jsleavescliponaxisout on purpose and I kept it that way.Tests:
scattergl_test.jssupplyDefaultsonly coercescliponaxisfor traces with markers.scatter2dandselect2d. It covers a circle with a border, a square, array sizes and line widths, and aselectedsize. A restyle back tocliponaxis: trueputs the viewport back on the plot area.gl2d_plot_interact_test.js: the marker range stays padded during and after a pan. The line range doesn't change.gl2d_cliponaxis_false. The left subplot usescliponaxis: falseand the right one uses the default, which is howscattergllooks today. It has no baseline yet. I'll add the one from the CI artifact.On my machine (macOS, Chrome 158)
scattergl,scattergl_select,gl2d_plot_interact,gl2d_click,scatterpolarglandsplompass. The one exception ishover with (x|y)period positioningand that one fails onmainhere too. The existingscattergl,scatterpolarglandsplommocks render the same as onmainso no existing baseline changes.npm run regl-codegengives no changes either.Assisted by Claude Code.