Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging the `enter` selectin into the `update` selections

D3 documentation says:

The enter selection merges into the update selection when you append or insert. This approach reduces code duplication between enter and update. Rather than applying operators to both the enter and update selection separately, you can now apply them to the update selection after entering the nodes. In the rare case that you want to run operators only on the updating nodes, you can run them on the update selection before entering new nodes.

I don't understand the meaning of the phrase merge into in the first sentence. Can someone explain this bit? (Perhaps I'm missing a connection with some standard database terminology?)

like image 399
max Avatar asked Oct 04 '22 09:10

max


1 Answers

This means that after you've applied an append or insert operation to the enter selection, its elements will be part of the update selection. That is, you increase the size of the update selection. The purpose of this is, as the documentation says, to reduce code duplication. After appending a new element, various attributes have to set (e.g. size, color, position). The same attributes have to be set for elements that are updated in many cases and the same code can be used.

The database equivalent would be selecting rows from different tables (enter and update) and then applying some operation to the rows selected from enter to add them to update. This analogy doesn't work entirely, but it may help you understand what's going on.

like image 160
Lars Kotthoff Avatar answered Oct 13 '22 10:10

Lars Kotthoff