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

issues when doing .transition(t) #129

Closed
theiliad opened this issue Jul 16, 2021 · 6 comments
Closed

issues when doing .transition(t) #129

theiliad opened this issue Jul 16, 2021 · 6 comments

Comments

@theiliad
Copy link

Hi
I think there might be a bug in 3.0 when doing

const t = transition().duration(750);

selectAll("blah blah...")
   .transition(t)
   .attr('opacity', 1);

I keep seeing the error
Error: transition 1 not found

I'm using a factory for transitions, and it's been working in previous versions, but updating to 3.0 keeps giving me this error

@mbostock
Copy link
Member

Per the README, emphasis added:

If the name is a transition instance, the returned transition has the same id and name as the specified transition. If a transition with the same id already exists on a selected element, the existing transition is returned for that element. Otherwise, the timing of the returned transition is inherited from the existing transition of the same id on the nearest ancestor of each selected element. Thus, this method can be used to synchronize a transition across multiple selections, or to re-select a transition for specific elements and modify its configuration.

If you’re seeing this error, it’s either because (1) the transition has expired (not evident from your code snippet, but you didn’t share a complete working example so it’s impossible to say) or (2) the “blah blah” elements you are selecting are not descendant elements of the transition t.

@mbostock
Copy link
Member

(This happens in 3.0 because of #59; in earlier versions, it would silently ignore the t argument when the transition was not found.)

@theiliad
Copy link
Author

theiliad commented Jul 21, 2021

@mbostock I'm usually good w reading the d3 docs and figuring stuff out, however I still don't understand what could be happening.

Here's how I use transitions:

I've got a factory:
https://github.com/carbon-design-system/carbon-charts/blob/8c27e54319d8aabcccdfcee211acc0c669572cef/packages/core/src/services/essentials/transitions.ts#L20-L39

And I use it like so:
https://github.com/carbon-design-system/carbon-charts/blob/8c27e54319d8aabcccdfcee211acc0c669572cef/packages/core/src/components/axes/grid.ts#L100-L103

That's all working in 5.x, now trying to upgrade to 6.x or 7.x I keep seeing transition 1 not found

I might've misread your docs, but as a naive fix I tried adding an incrementing ID in my factory

image

and I still get the same error.

Could you pls clarify what needs to change?

@theiliad
Copy link
Author

I still feel like I'm not understanding how transitions are supposed to be working

Is this better?

image

image

@theiliad
Copy link
Author

bumping

@theiliad
Copy link
Author

theiliad commented Aug 4, 2021

In case anyone else is having these kinds of issues. I ended up using .call() to handle my transitions

image

image

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

No branches or pull requests

2 participants