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

Add selection.context. #35

Closed
wants to merge 1 commit into from
Closed

Add selection.context. #35

wants to merge 1 commit into from

Conversation

mbostock
Copy link
Member

I’m not sure about this API. It’s nice to have something that can capture the context of a selection.each (or selection.attr, selection.data, etc.). But it’s a bit weird that you have to pass in arguments and then have the selection recompute the ancestors.

Also, sometimes you might want to access the current group or the parent node within a callback. The selection.context can determine those things, but doesn’t expose them.

Also, within a selection.each (or most other selection methods) callback, you don’t have easy access to the current selection because the this context is set to the current element. So maybe an approach like d3.event is more suitable? Like, say, d3.context() could be a magic method that only works within selection.each, and returns the context for the current selection.

@mbostock
Copy link
Member Author

Also, it might not be necessary to expose this functionality if transition events went through the selection.dispatch mechanism… though it does seem reasonable to want access to ancestors within a callback.

@mbostock mbostock closed this Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant