source: node_modules/d3-shape/src/order/insideOut.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 518 bytes
Line 
1import appearance from "./appearance.js";
2import {sum} from "./ascending.js";
3
4export default function(series) {
5 var n = series.length,
6 i,
7 j,
8 sums = series.map(sum),
9 order = appearance(series),
10 top = 0,
11 bottom = 0,
12 tops = [],
13 bottoms = [];
14
15 for (i = 0; i < n; ++i) {
16 j = order[i];
17 if (top < bottom) {
18 top += sums[j];
19 tops.push(j);
20 } else {
21 bottom += sums[j];
22 bottoms.push(j);
23 }
24 }
25
26 return bottoms.reverse().concat(tops);
27}
Note: See TracBrowser for help on using the repository browser.