Skip to content

fix: skip the recalc after a range change of constrained axes of regl traces - #2

Draft
katosh wants to merge 1 commit into
mainfrom
pr/gl2d-scaleanchor
Draft

katosh wants to merge 1 commit into
mainfrom
pr/gl2d-scaleanchor

Conversation

@katosh

@katosh katosh commented Dec 4, 2026

Copy link
Copy Markdown

Description

A zoom or pan on axes with scaleanchor no longer recalculates scattergl traces, if each constrained axis holds a fixed range. With 5 million points, a pan step takes 72 ms, against 908 ms on main. The change is not opt-in, and the constraint holds as before.

Closes #

Bar chart: a pan step takes 180 ms and 908 ms on main, and 17 ms and 72 ms on this branch
One pan step by Plotly.relayout with yaxis.scaleanchor and fixed ranges, main against this branch. Median of 10 steps, ten traces, strict bundles, Apple M3 Max, headless Chromium on ANGLE Metal.

_relayout sets flags.calc when a relayout alters the range of an axis in a constraint group. For regl traces, each zoom step then recalculates every trace and uploads every point again.

The replot applies the constraints from the axes. Only an autorange needs the extremes that a recalc adds. Now the relayout sets flags.plot, if every trace is a regl trace and every axis of the group has a fixed range. In every other case, the recalc stays.

AnnZarro draws embeddings with an equal aspect ratio in plotly.js and needs this. Overview: [combined draft PR link].

Changes

  • src/plot_api/plot_api.js: new function constraintsNeedCalc
  • test/jasmine/tests/plot_api_test.js: 1 new spec for the replot and for the cases that keep the recalc
  • test/jasmine/tests/gl2d_plot_interact_test.js: 1 new spec for the ratio after a zoom, a pan and a relayout

Testing

  • plot_api: 172 specs pass, and main has 171
  • gl2d_plot_interact: 17 specs pass, and main has 16
  • cartesian passes

Notes

  • No spec covers constrain: 'domain' or several constraint groups yet. I can add them.
  • A pan step on this branch uploads 17 bytes for each point. A range relayout without scaleanchor uploads the same bytes on main.
  • The cause: each replot calls scatter2d.update with the marker options, and regl-scatter2d 3.4.0 then uploads the positions again. The scattergl typed-arrays pull request (link follows) removes this upload.
  • plotly.min.js grows by 325 bytes

I can reshape or withdraw this pull request. Thank you for your time.

Checklist

  • The linked issue has the ready-for-pr label, and it has no assignee or lists me as an assignee
  • I opened the pull request from a branch other than main in my fork
  • I selected "Allow edits from maintainers"
  • I did not edit files in dist/
  • I committed package-lock.json only for a dependency change
  • I added a file to draftlogs/ as draftlogs/README.md describes, or I will add one after the pull request opens

_relayout set flags.calc when a relayout altered the range of an axis in a constraint group. For regl traces, each zoom step then recalculated every trace and uploaded every point again.

The replot applies the constraints from the axes. Only an autorange needs the extremes of a new calc. The relayout now sets flags.plot, if every trace is a regl trace and every axis of the group has a fixed range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant