Skip to content

[BUG]: Background image is rendered at an incorrect size after box zoom followed by mouse wheel zoom out #7914

Open

Description

@JulienIcon

Description

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.

Screenshots/Video

plotly_image_bug.mp4

Steps to reproduce

Here https://codepen.io/JulienIcon/pen/QwdBypd, try to box zoom a small part of the chart and then try to manually zoom out using the mouse wheel

Notes

If the zoom is reset using the default double-click interaction, the background image is rendered correctly again.

Activity

  1. added
    bug
    on Jul 21, 2026
  2. camdecoster commented on Jul 21, 2026

    @camdecoster
    Contributor

    Thanks for the report! Could you see if this is still happening with the latest RC?

  3. JulienIcon commented on Jul 22, 2026

    @JulienIcon
    ContributorAuthor

    I tested it with this latest RC, and the issue is still reproducible

  4. camdecoster commented on Jul 22, 2026

    @camdecoster
    Contributor

    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.

  5. added
    good-first-issue
    on Jul 22, 2026
  6. nightcityblade commented on Jul 23, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  7. added
    P2
    on Jul 23, 2026
  8. robertclaus commented on Jul 23, 2026

    @robertclaus

    @nightcityblade that would be great! Thank you!

  9. JulienIcon commented on Jul 24, 2026

    @JulienIcon
    ContributorAuthor
  10. devtitus commented on Sep 9, 2026

    @devtitus

    Hi, if this issue is still active, I would like to give a try on this.

  11. emilykl commented on Sep 9, 2026

    @emilykl
    Contributor

    @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.

  12. dnstroupe commented on Nov 27, 2026

    @dnstroupe

    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.

  13. added
    ready-for-pr
    on Nov 30, 2026
  14. dnstroupe commented on Nov 30, 2026

    @dnstroupe

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2buggood-first-issuegood-for-agentready-for-prsize: 1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions