selection.empty()

selection.empty() Returns true if this selection contains no (non-null) elements.

selection.each()

selection.each(function) Invokes the specified function for each selected element, passing in passed the current datum (d), the current index (i), and the current group (nodes), with this of the current DOM element. This method can be used to invoke arbitrary code for each selected element, and is useful for creating a context to access parent and child data simultaneously, such as: parent.each(function(p, j) { d3.select(this) .selectAll(".child") .text(function(d, i) { return "c

selection.dispatch()

selection.dispatch(type[, parameters]) Dispatches a custom event of the specified type to each selected element, in order. An optional parameters map may be specified to set additional properties of the event. It may contain the following fields: bubbles - if true, the event is dispatched to ancestors in reverse tree order. cancelable - if true, event.preventDefault is allowed. detail - any custom data associated with the event. If parameters is a function, it is evaluated for each sele

selection.datum()

selection.datum([value]) Gets or sets the bound data for each selected element. Unlike selection.data, this method does not compute a join and does not affect indexes or the enter and exit selections. If a value is specified, sets the element’s bound data to the specified value on all selected elements. If the value is a constant, all elements are given the same datum; otherwise, if the value is a function, then the function is evaluated for each selected element, in order, being passed the

selection.data()

selection.data([data[, key]]) Joins the specified array of data with the selected elements, returning a new selection that it represents the update selection: the elements successfully bound to data. Also defines the enter and exit selections on the returned selection, which can be used to add or remove elements to correspond to the new data. The specified data is an array of arbitrary values (e.g., numbers or objects), or a function that returns an array of values for each group. When data

selection.classed()

selection.classed(names[, value]) If a value is specified, assigns or unassigns the specified CSS class names on the selected elements by setting the class attribute or modifying the classList property and returns this selection. The specified names is a string of space-separated class names. For example, to assign the classes foo and bar to the selected elements: selection.classed("foo bar", true); If the value is truthy, then all elements are assigned the specified classes; otherwise, the

selection.call()

selection.call(function[, arguments…]) Invokes the specified function exactly once, passing in this selection along with any optional arguments. Returns this selection. This is equivalent to invoking the function by hand but facilitates method chaining. For example, to set several styles in a reusable function: function name(selection, first, last) { selection .attr("first-name", first) .attr("last-name", last); } Now say: d3.selectAll("div").call(name, "John", "Snow"); This is

selection.attrs()

selection.attrs(values) A convenience method on top of selection.attr for setting multiple attributes. If the specified values is an object, the values may be specified either as strings or functions. For example: selection.attrs({foo: "foo-value", bar: function(d) { return d.bar; }}); If a value is a constant, all elements are given the same attribute value; otherwise, if a value is a function, the function is evaluated for each selected element, in order, being passed the current datum (d),

selection.attr()

selection.attr(name[, value]) If a value is specified, sets the attribute with the specified name to the specified value on the selected elements and returns this selection. If the value is a constant, all elements are given the same attribute value; otherwise, if the value is a function, the function is evaluated for each selected element, in order, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element. The function’s

selection.append()

selection.append(type) If the specified type is a string, appends a new element of this type (tag name) as the last child of each selected element, or the next following sibling in the update selection if this is an enter selection. (The enter behavior allows you to insert elements into the DOM in an order consistent with bound data; however, the slower selection.order may still be required if updating elements change order.) Otherwise, the type may be a function which is evaluated for each