Accept function for selection append and insert.
Like selection.select, selection.append and selection.insert can now accept a function which returns a node. This makes it slightly easier to append or insert elements whose name is computed from data, or to append elements that already exist (say from an element pool). There has been much discussion regarding whether the function should return the name of the element or the element itself. Returning a name is less work for the caller, but only supports creating new elements; returning a name is also more consistent with how D3 defines attribute values, but D3 does not allow attribute names to be specified as functions. So, it seemed better to opt for consistency with selection.select and selection.selectAll, which accept functions that return elements, since this is more expressive. Of course, you can still use select and selectAll to append elements, but using append to do that directly is more intuitive. Related #4 #311 #724 #732 #734 #961 #1031 #1271.
This source diff could not be displayed because it is too large. You can view the blob instead.
Please register or sign in to comment