nest.sortValues()

nest.sortValues(comparator) Sorts leaf elements using the specified comparator function, such as d3.ascending or d3.descending. This is roughly equivalent to sorting the input array before applying the nest operator; however it is typically more efficient as the size of each group is smaller. If no value comparator is specified, elements will be returned in the order they appeared in the input array. This applies to nest.map, nest.entries and nest.object.

nest.sortKeys()

nest.sortKeys(comparator) Sorts key values for the current key using the specified comparator function, such as d3.ascending or d3.descending. If no comparator is specified for the current key, the order in which keys will be returned is undefined. For example, to sort years in ascending order and varieties in descending order: var entries = d3.nest() .key(function(d) { return d.year; }).sortKeys(d3.ascending) .key(function(d) { return d.variety; }).sortKeys(d3.descending) .entri

nest.rollup()

nest.rollup(function) Specifies a rollup function to be applied on each group of leaf elements. The return value of the rollup function will replace the array of leaf values in either the associative array returned by nest.map or nest.object; for nest.entries, it replaces the leaf entry.values with entry.value.

nest.object()

nest.object(array) Applies the nest operator to the specified array, returning a nested object. Each entry in the returned associative array corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an additional key, the value is another associative array; otherwise, the value is the array of elements filtered from the input array that have the given key value. Note: this method is unsafe if any of

nest.map()

nest.map(array) Applies the nest operator to the specified array, returning a nested map. Each entry in the returned map corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an additional key, the value is another map; otherwise, the value is the array of elements filtered from the input array that have the given key value. If no keys are defined, returns the input array.

nest.key()

nest.key(key) Registers a new key function. The key function will be invoked for each element in the input array and must return a string identifier to assign the element to its group. Most often, the function is a simple accessor, such as the year and variety accessors above. (Keys functions are not passed the input array index.) Each time a key is registered, it is pushed onto the end of the internal array of keys, and the nest operator applies an additional level of nesting.

nest.entries()

nest.entries(array) Applies the nest operator to the specified array, returning an array of key-values entries. Conceptually, this is similar to applying map.entries to the associative array returned by nest.map, but it applies to every level of the hierarchy rather than just the first (outermost) level. Each entry in the returned array corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an add

map.values()

map.values() Returns an array of values for every entry in this map. The order of the returned values is arbitrary.

map.size()

map.size() Returns the number of entries in this map.

map.set()

map.set(key, value) Sets the value for the specified key string. If the map previously had an entry for the same key string, the old entry is replaced with the new value. Returns the map, allowing chaining. For example: var map = d3.map() .set("foo", 1) .set("bar", 2) .set("baz", 3); map.get("foo"); // 1