Taking this to the next logical step, then, what if we have no existing elements? Meaning, what if the document is empty? Say we start with an empty page, and we want to create new circles that correspond to our data? Then we’re joining data to an empty selection, and all of the data ends up in enter:
var enter = circle.enter().append("circle"); enter.attr("cy", 90); enter.attr("cx", function(d) { return d; }); enter.attr("r", function(d) { return Math.sqrt(d); });
This pattern is so common, you’ll often see the selectAll + data + enter + append operators called sequentially, one immediately after the other. Despite it being common, keep in mind that this is just one special case of a data join; we’ve already seen another common case (selecting elements for update) and we’ll see other interesting cases to consider in a bit.