Skip to content
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

Minor fixes to allow null frames internally #1121

Merged
merged 3 commits into from
Nov 9, 2016
Merged

Minor fixes to allow null frames internally #1121

merged 3 commits into from
Nov 9, 2016

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Nov 8, 2016

This PR adds a small test and a couple fixes to prevent plotly from breaking on null frames. This is necessary for transforms that directly add or remove frames. If they remove frames, they should avoid compressing the array so that indices don't change. This means null or undefined entries in the frame array should simply be ignored.

@etpinard etpinard added bug something broken status: in progress labels Nov 8, 2016
@etpinard etpinard added this to the v1.20.0 milestone Nov 8, 2016
@etpinard
Copy link
Contributor

etpinard commented Nov 8, 2016

fyi @rreusser you'll need to merge master to make

image

pass again.

@@ -2399,6 +2399,8 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
for(i = 0; i < trans._frames.length; i++) {
frame = trans._frames[i];

if(!frame) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

so, technically, not just null is special. Any non-numeric i would make trans._frames[i] falsy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can't be non-numeric since it's the array index. This is a check to see if the accessed frame is falsey. Perhaps a better check is if (!Lib.isPlainObject(frame)).

@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

Making Plotly.animate and friends skip over blank frames makes sense. Thanks for cleaning that up 🍻

I wonder though, if we could expose a way through Plotly.animate to make a graph go back to its original "data" / "layout"` settings?

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

Short answer… no. I don't see any way to accomplish this without structural changes to animation. As discussed previously, I think the solution would be frames that you would toggle on/off. On each data -> fullData step, it would merge any 'on' frames. Turning the frames off would restore it to the original state.

@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

Thanks for the reply @rreusser

Turning the frames off would restore it to the original state.

This would certainly make layout.breakpoints frames easier to deal with.

Perhaps (or not) this could as easy as adding a type key to the frame attributes. type would be an enumerated with possible values: 'sequencial' and 'toggle'.

@rreusser
Copy link
Contributor Author

rreusser commented Nov 9, 2016

Yeah, I think with all the other machinery in place and with a much better understanding of what we're after that this might actually not be so difficult. The reason this wasn't done to begin with is that one solution cannot handle both ephemeral update-and-forget-about-it updates and stateless toggle updates. I think it would be worthwhile though.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Conflicts:
	test/jasmine/tests/animate_test.js
@etpinard
Copy link
Contributor

etpinard commented Nov 9, 2016

💃

@rreusser rreusser merged commit 2ac3dd7 into master Nov 9, 2016
@etpinard etpinard deleted the null-frames branch November 9, 2016 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants