Skip to content

Conversation

@BJohnBraddock
Copy link

@BJohnBraddock BJohnBraddock commented Dec 20, 2025

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
Contributor

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

@BJohnBraddock
Copy link
Author

before.mp4
after.mp4

animate_scattergl.json

Copy link
Contributor

@camdecoster camdecoster left a comment

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 on lines +266 to +269
for(i = 0; i < cdata.length; i++) {
var cdscatter = cdata[i];
if(!cdscatter || !cdscatter[0]) continue;
var cd0 = cdscatter[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could simplify this further. We know that cdata has a length from line 39.

Suggested change
for(i = 0; i < cdata.length; i++) {
var cdscatter = cdata[i];
if(!cdscatter || !cdscatter[0]) continue;
var cd0 = cdscatter[0];
for (const [cd0] of cdata) {
if (!cd0) continue;

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.

ScatterGL throws TypeError: r[v] is undefined when using frames bug when animating Scattergl

2 participants