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

Enable the use of d3.join() without implicit d3.order() call #299

Closed
NeonMika opened this issue Feb 19, 2022 · 3 comments
Closed

Enable the use of d3.join() without implicit d3.order() call #299

NeonMika opened this issue Feb 19, 2022 · 3 comments

Comments

@NeonMika
Copy link

NeonMika commented Feb 19, 2022

I switched one of my applications from the "old" enter()/merge() pattern to use the "new" join() method.
I really like how concise data binding becomes using this method.
Sadly, only after this move I found out that join() automatically performs order() after the merge of the enter and update selection.

Possible improvement: Since my application relies on preserving the document order, and data array reordering is not really feasable in my case, I would like to ask whether it is possible to add an additional (optional) parameter to the join() method that allows users to specify whether they want to automatically perform order() at the end of the join method. Probably somethink like an options parameter.

An example for this problem can be found here: https://stackoverflow.com/q/71179024/2938364

The problematic line is

return enter && update ? enter.merge(update).order() : update;

@Fil
Copy link
Member

Fil commented Feb 19, 2022

ordering is not an implicit byproduct of selection.join, but an explicit part of the feature as mentioned in the documentation and in the unit test: 146af5d

Have you considered applying selection.sort after the join()?

@NeonMika
Copy link
Author

NeonMika commented Feb 19, 2022

Yes, I read the documentation (after searching for quite some time why the z-ordering problem occurs - first I assumed some problem with my drag code), and yes, probably I used the word "implicit" wrong in this context.

But I do no think that ordering (in join), sorting, and then ordering (in sort) again is the way how this problem should be tackeled.

I think there are use cases where it is not desired that join calls order at the end, and I just think that it would be nice if it was possible to call join with this setting (either by adding a parameter to join or by providing another method similar to join that does not order the selection in the end).

Otherwise, methods such as raise and lower lose their applicability in data-joined visualization, since they will be "overridden" on the next join call.

@mbostock
Copy link
Member

selection.join is a convenience function. If you don’t want to order, you should call the underlying methods directly yourself. We shouldn’t add options to selection.join.

@Fil Fil closed this as completed Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants