-
Notifications
You must be signed in to change notification settings - Fork 87
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
Why have an insert
method?
#63
Comments
Hi Sam, We do this so that the context of the More than just being a technical requirement, we think this also promotes chart legibility. The logic that dictates how elements are created is fundamental to the chart's definition, so we want that encapsulated in an explicit function--not declared within one (of many) lifecycle event handlers. Does that clear things up? |
Hmm, the code is a bit over my head. I can't quit understand that point. Couldn't you defer the insertion operation simply by invoking the Perhaps it would help me understand if you explained why we wouldn't do the same for removing elements. That is, why don't we have an explicit function for Thanks for your time + quick response Mike! |
Actually, we could, but modifying the selection in place means that each handler could be dealing with a different set of elements. If we promote a pattern where any lifecycle event handler may add elements to the set, the value of
I think we document removing nodes in in |
Ah, I think I'm starting to understand. I haven't worked with complex enough extensions where I've written multiple handlers for the same event. You're saying that if one of those handlers While I have you - how exactly does |
To clarify - are you saying that even if you |
Hey @samselikoff, I think this is good justification for a dedicated function() {
this.remove();
} would seem to be sensible and shouldn't cause too much confusion when people migrate to the next release. If you'd like to give it a shot, I'd be more than happy to help you implement this feature. Otherwise, just let me know and I'll give it a go myself. |
I'd love to try and implement this, and really appreciate your help! So by default, the exit selection will get |
Yup, that sounds about right |
@jugglinmike it would need to go after the events loop, so I don't fully grok this code yet, I was expecting |
You have the right idea. The |
Hello,
I'm trying to wrap my head around the
insert
method. In the world of vanilla D3, we typically append elements within theenter
selection:In d3.chart, we'd do something like this:
My question is, why not just append the elements in the enter lifecycle event? I may not be reading it right, but isn't this what the relevant code is essentially doing?
The only info I've been able to find about this was in Irene's blog post:
But isn't appending elements a data-driven operation, and therefore doesn't it belong in the
enter
lifecycle event?I think I'm just missing something here - would love some clarification.
Thanks!
The text was updated successfully, but these errors were encountered: