-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix scattergl animation index out of range in for loop #7676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix scattergl animation index out of range in for loop #7676
Conversation
|
Thanks for the PR! Before we review, could you please provide some videos showing the change? |
before.mp4after.mp4 |
camdecoster
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for(i = 0; i < cdata.length; i++) { | ||
| var cdscatter = cdata[i]; | ||
| if(!cdscatter || !cdscatter[0]) continue; | ||
| var cd0 = cdscatter[0]; |
There was a problem hiding this comment.
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.
| 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; |
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
cdatawith variableibecause variableicomes 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.