You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: Background image is rendered at an incorrect size after box zoom followed by mouse wheel zoom out #7914
On charts containing a background image with xref: "x" and yref: "y", performing a box zoom followed by a manual zoom out causes the background image to be rendered with an incorrect size and position. It no longer matches the coordinate system defined by xref and yref.
Then it's a bug! Thanks for checking. Our team probably won't be able to look at this for a while, but we can prioritize a PR review if you want to work on it.
I traced the wheel path in src/plots/cartesian/dragbox.js. Each wheel event calls updateSubplots(scrollViewBox) and ticksAndAnnotations() before emitting plotly_relayouting; the delayed callback then resets scrollViewBox and calls dragTail(). Axes.redrawComponents already requests an image redraw, so I'd first distinguish a transient transform from a bad final layout. A regression fixture could place markers at two opposite corners of an axis-referenced image (xanchor: 'left', yanchor: 'top', sizing: 'stretch'). Compare their screen coordinates with the image bounds after box zoom, during wheel zoom, and after the delayed relayout. Measuring both corners distinguishes scaling drift from a constant offset. This is a source trace and proposed diagnostic; I haven't independently reproduced the gesture.
I inspected the CodePen configuration: its axis-referenced image uses sizing: "contain", with left/bottom alignment. I tested that configuration in a reduced scattergl chart in Chrome on Plotly.js 4.0.0 and 4.3.1, using an image with the same 1280:394 aspect ratio. A narrow box zoom changes the aspect ratio of the area defined by the data coordinates. The SVG image box tracked the axis extents at every sampled stage (0.00 CSS px error to two decimals). With contain, the unused width calculated from the rendered SVG sizing mode was 697.6 px after the box zoom and 313.5 px once the wheel zoom settled. With stretch the unused space was zero on both axes.
For an image calibrated to data coordinates, try changing only sizing to "stretch". This will distort the picture when the axes scale independently, but its edges follow both data extents. The reduced case is consistent with aspect-ratio preservation; I haven't established a renderer defect in the original chart. If it still drifts with stretch, a recording of that case would help distinguish a second issue.
Runnable comparison and animated chart exports. To run locally, open evidence/zoom.html from that branch using a static server at the repository root. The PASS/FAIL indicator tests the specific requirement that the picture fill both data extents.
Activity
camdecoster commentedon Jul 21, 2026
Thanks for the report! Could you see if this is still happening with the latest RC?
JulienIcon commentedon Jul 22, 2026
I tested it with this latest RC, and the issue is still reproducible
camdecoster commentedon Jul 22, 2026
Then it's a bug! Thanks for checking. Our team probably won't be able to look at this for a while, but we can prioritize a PR review if you want to work on it.
nightcityblade commentedon Jul 23, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.
robertclaus commentedon Jul 23, 2026
@nightcityblade that would be great! Thank you!
JulienIcon commentedon Jul 24, 2026
Thanks @nightcityblade !
devtitus commentedon Sep 9, 2026
Hi, if this issue is still active, I would like to give a try on this.
emilykl commentedon Sep 9, 2026
@devtitus Sure, go for it! The issue still exists in the latest plotly.js v4.0.0.
We recommend that you start by investigating and proposing a potential fix in this issue thread before opening a PR.
dnstroupe commentedon Nov 27, 2026
I traced the wheel path in
src/plots/cartesian/dragbox.js. Each wheel event callsupdateSubplots(scrollViewBox)andticksAndAnnotations()before emittingplotly_relayouting; the delayed callback then resetsscrollViewBoxand callsdragTail().Axes.redrawComponentsalready requests an image redraw, so I'd first distinguish a transient transform from a bad final layout. A regression fixture could place markers at two opposite corners of an axis-referenced image (xanchor: 'left',yanchor: 'top',sizing: 'stretch'). Compare their screen coordinates with the image bounds after box zoom, during wheel zoom, and after the delayed relayout. Measuring both corners distinguishes scaling drift from a constant offset. This is a source trace and proposed diagnostic; I haven't independently reproduced the gesture.dnstroupe commentedon Nov 30, 2026
I inspected the CodePen configuration: its axis-referenced image uses
sizing: "contain", with left/bottom alignment. I tested that configuration in a reduced scattergl chart in Chrome on Plotly.js 4.0.0 and 4.3.1, using an image with the same 1280:394 aspect ratio. A narrow box zoom changes the aspect ratio of the area defined by the data coordinates. The SVG image box tracked the axis extents at every sampled stage (0.00 CSS px error to two decimals). With contain, the unused width calculated from the rendered SVG sizing mode was 697.6 px after the box zoom and 313.5 px once the wheel zoom settled. With stretch the unused space was zero on both axes.For an image calibrated to data coordinates, try changing only
sizingto"stretch". This will distort the picture when the axes scale independently, but its edges follow both data extents. The reduced case is consistent with aspect-ratio preservation; I haven't established a renderer defect in the original chart. If it still drifts with stretch, a recording of that case would help distinguish a second issue.Runnable comparison and animated chart exports. To run locally, open evidence/zoom.html from that branch using a static server at the repository root. The PASS/FAIL indicator tests the specific requirement that the picture fill both data extents.