Spaces:
Build error
Build error
File size: 1,428 Bytes
c211499 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import array from "./array.js";
import constant from "./constant.js";
import offsetNone from "./offset/none.js";
import orderNone from "./order/none.js";
function stackValue(d, key) {
return d[key];
}
function stackSeries(key) {
const series = [];
series.key = key;
return series;
}
export default function() {
var keys = constant([]),
order = orderNone,
offset = offsetNone,
value = stackValue;
function stack(data) {
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, sz[i].key, j, data)]).data = d;
}
}
for (i = 0, oz = array(order(sz)); i < n; ++i) {
sz[oz[i]].index = i;
}
offset(sz, oz);
return sz;
}
stack.keys = function(_) {
return arguments.length ? (keys = typeof _ === "function" ? _ : constant(Array.from(_)), stack) : keys;
};
stack.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
};
stack.order = function(_) {
return arguments.length ? (order = _ == null ? orderNone : typeof _ === "function" ? _ : constant(Array.from(_)), stack) : order;
};
stack.offset = function(_) {
return arguments.length ? (offset = _ == null ? offsetNone : _, stack) : offset;
};
return stack;
}
|