Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept iterables. #153

Merged
merged 18 commits into from
Aug 19, 2020
Prev Previous commit
Next Next commit
Allow stack.keys function to return an iterable.
  • Loading branch information
mbostock committed Nov 19, 2019
commit 3c9bd9ea7318f4aa416f622219826fba774cf9f8
5 changes: 2 additions & 3 deletions src/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ export default function() {
value = stackValue;

function stack(data) {
var kz = keys.apply(this, arguments),
sz = kz.map(stackSeries),
var sz = Array.from(keys.apply(this, arguments), stackSeries),
i, n = sz.length, j = -1,
oz;

for (const d of data) {
for (i = 0, ++j; i < n; ++i) {
(sz[i][j] = [0, +value(d, kz[i], j, data)]).data = d;
(sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d;
}
}

Expand Down