Skip to content

Fix scattergl animation index out of range in for loop#7676

Merged
camdecoster merged 7 commits into
plotly:masterfrom
BJohnBraddock:fix-6251/scattergl-animation
Jan 16, 2026
Merged

Fix scattergl animation index out of range in for loop#7676
camdecoster merged 7 commits into
plotly:masterfrom
BJohnBraddock:fix-6251/scattergl-animation

Conversation

@BJohnBraddock

@BJohnBraddock BJohnBraddock commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

Goal: Fix runtime error when "animating" scattergl traces. I don't believe scattergl traces actually support animations like easing and redraw=False, but they should at least not hit a runtime error.

As shown in #6251 , there is an unsafe index into cdata with variable i because variable i comes from scene.count and not cdata.length. This is normally fine. However, during frame redraw animations, we may call scattergl.plot with a subset of calcdata, so cdata.length can be < scene.count.

Further up in traces/scattergl/plot.py there was already an instance of checking if cdata[i] is undefined, so I've mirrored that into the for loop.

Fixes #6251.
This should also fix #6897 which is the same error as #6251.

@camdecoster

Copy link
Copy Markdown
Contributor

Thanks for the PR! Before we review, could you please provide some videos showing the change?

@BJohnBraddock

Copy link
Copy Markdown
Contributor Author
before.mp4
after.mp4

animate_scattergl.json

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! It does take care of #6251 and #6897. I made a small syntax suggestion.

Comment thread src/traces/scattergl/plot.js Outdated
Co-authored-by: Cameron DeCoster <cameron.decoster@gmail.com>
@BJohnBraddock BJohnBraddock force-pushed the fix-6251/scattergl-animation branch from 7c19822 to 57c2f5f Compare January 15, 2026 03:37
@camdecoster camdecoster merged commit 8661619 into plotly:master Jan 16, 2026
4 of 5 checks passed
@BJohnBraddock BJohnBraddock deleted the fix-6251/scattergl-animation branch January 16, 2026 01:42
@BJohnBraddock

Copy link
Copy Markdown
Contributor Author

Thanks for the review @camdecoster !

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

Labels

None yet

2 participants