MCPcopy Create free account
hub / github.com/breck7/scroll / selection_data

Function selection_data

external/.d3.js:1905–1942  ·  view source on GitHub ↗
(value, key)

Source from the content-addressed store, hash-verified

1903}
1904
1905function selection_data(value, key) {
1906 if (!arguments.length) return Array.from(this, datum);
1907
1908 var bind = key ? bindKey : bindIndex,
1909 parents = this._parents,
1910 groups = this._groups;
1911
1912 if (typeof value !== "function") value = constant$a(value);
1913
1914 for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
1915 var parent = parents[j],
1916 group = groups[j],
1917 groupLength = group.length,
1918 data = arraylike(value.call(parent, parent && parent.__data__, j, parents)),
1919 dataLength = data.length,
1920 enterGroup = enter[j] = new Array(dataLength),
1921 updateGroup = update[j] = new Array(dataLength),
1922 exitGroup = exit[j] = new Array(groupLength);
1923
1924 bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
1925
1926 // Now connect the enter nodes to their following update node, such that
1927 // appendChild can insert the materialized enter node before this node,
1928 // rather than at the end of the parent node.
1929 for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
1930 if (previous = enterGroup[i0]) {
1931 if (i0 >= i1) i1 = i0 + 1;
1932 while (!(next = updateGroup[i1]) && ++i1 < dataLength);
1933 previous._next = next || null;
1934 }
1935 }
1936 }
1937
1938 update = new Selection$1(update, parents);
1939 update._enter = enter;
1940 update._exit = exit;
1941 return update;
1942}
1943
1944// Given some data, this returns an array-like view of it: an object that
1945// exposes a length property and allows numeric indexing. Note that unlike

Callers

nothing calls this directly

Calls 4

constant$aFunction · 0.85
arraylikeFunction · 0.85
bindFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected