Skip to content

(ui) - Halve the cost of panning the trace - #4

Merged
Skitionek merged 2 commits into
mainfrom
fix-pan-redraw-cost
Oct 23, 2026
Merged

Skitionek merged 2 commits into
mainfrom
fix-pan-redraw-cost

Conversation

@Skitionek

Copy link
Copy Markdown
Member

What

Panning with annotations loaded now costs about 33 ms of main-thread time instead of 70 ms (18 ms instead of 31 ms without annotations), and the plot, range slider and tooltips look and behave as before. Plotly now draws only the invisible Basecall hover markers that are in view, and the arrow shape paths are re-sent only when the zoom moves more than 5%.

Why

Each pan restyled all 1,453 hover markers twice, and re-sending the arrow paths made Plotly replot the whole figure instead of only moving the axis. Together they were more than half the pan cost.

Decision

WebGL (scattergl) peaks were tried first and dropped: they save about 10 ms per pan, but Plotly's range slider draws only SVG traces, so the overview went blank. maxdisplayed: 1 or mode: 'none' were as fast as the cap used here but lose the Basecall tooltip near the plot's bottom edge, because Plotly sets a marker's hover radius only when it draws it.

Not in this PR

  • With 20 or fewer bases in view, a one-base pan passes the 5% tolerance, so panning there still redraws the arrows. Drawing the heads as pixel-sized markers would remove the redraw altogether.
  • Fully zoomed out, every hover marker is in view and still drawn.
  • Tick labels (about 11 ms per pan) and the range slider redrawing the full trace are the next largest costs.

Coding assisted with Claude Opus 5.5

Plotly restyled all of the invisible Basecall hover markers on every
redraw, twice per pan, which was the largest part of the pan cost.
Setting marker.maxdisplayed makes Plotly draw only the markers inside
the axis ranges. With one per basecall it never thins out the ones in
view, so they keep their 16 px hover target and every tooltip stays
where it was.

Coding assisted with Claude Opus 5.5
Every pan re-sent all arrow shape paths with the xaxis3 sync, and any
shape-array edit makes Plotly replot the whole figure instead of only
updating the axis range. A pan moves the bases in view by a base or
so, which changes the fixed-size arrow heads by well under a pixel.

The paths are now sent only once bases-per-pixel has moved more than
5% from the zoom the arrows were last drawn at. Panning keeps the
cheap range-only relayout, and zooming still redraws the heads at
their full size.

Coding assisted with Claude Opus 5.5
@Skitionek
Skitionek marked this pull request as ready for review October 23, 2026 14:43
@Skitionek
Skitionek merged commit a2a6620 into main Oct 23, 2026
1 check passed
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