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

Implement Layer#remove #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jugglinmike
Copy link
Member

This configurable hook was initially designed in gh-63, and the implementation was proposed in gh-103. As discussed there, I'm following up with a few minor changes to finalize the implementation. Thanks for the help, @samselikoff!

Resolves gh-63

samselikoff and others added 3 commits June 28, 2015 19:06
Do not invoke a layer instance's `remove` handler if the `exit`
selection is empty.

This completes the implementation of `Layer#remove`.
@tbranyen
Copy link

Ah was confused by the title of this PR. So this is just adding the ability to override the behavior of remove?

@jugglinmike
Copy link
Member Author

This patch:

  • Implements Layer#remove (this is distinct from d3.selection#remove. Layer#remove was not previously defined, hence the title)
  • enables overriding of Layer#remove at layer creation time
  • extends the Layer#draw method to call Layer#remove with the appropriate selection and at the appropriate time in the lifecycle

@jugglinmike
Copy link
Member Author

@iros Would you mind taking a look?

@@ -216,4 +228,8 @@ Layer.prototype.draw = function(data) {
}
}
}

if (!selection.empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the reasoning behind calling remove on the selection if it's not empty? I might be missing some context here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for consistency with how we invoke the lifecycle events--see this logic in Layer#draw.

...but it's not really fair to answer a question like, "Why are we doing this here?" with, "because we're doing it over there." The underlying motivation was originally discussed in this issue: #69 .

Does this seem right to you?

Copy link
Member

Choose a reason for hiding this comment

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

So I think the way I would have approached it, is by doing the selection check here:
https://github.com/jugglinmike/d3.chart/blob/gh-103-extensions/src/layer.js#L217
and here:
https://github.com/jugglinmike/d3.chart/blob/gh-103-extensions/src/layer.js#L227

What I worry about is the remove routine having more destructive behavior (like removing parent containers that the selection would go into) that you might not want to execute unless you're effectively 'done' redrawing this layer or done with the chart itself (or perhaps you want to hide it somehow.)

Is there a reason we couldn't localize it to the specific lifecycle events and just not call the handlers?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there's a crossed wire here. Let's discuss this in person.

@iros
Copy link
Member

iros commented Jul 27, 2015

Added some questions @jugglinmike.

@jugglinmike
Copy link
Member Author

Added some responses, @iros :P

@iros
Copy link
Member

iros commented Jul 30, 2015

I responded to your responses @jugglinmike. 🍌 ➡️ 📫 = 🎉

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.

4 participants