new test block

This commit is contained in:
TreetopFlyer 2021-05-29 11:33:14 -04:00
parent b177f95fb7
commit 79cbbeb287
2 changed files with 38 additions and 14 deletions

View File

@ -31,12 +31,8 @@ var Pivot =
},
Pivot(inRoot, inParent, inPivotIndicies, inSumIndicies, inDepth)
{
//arguments:
// - a Node with leaf Nodes temporarily stored in its Meta.Leaves
// - where each leaf Node has a row of table data in it's Meta.Row
// - a list of columns to pivot on
// - a list of columns to sum
// - optional traversal depth, defaults to 0
let depth = inDepth||0;
let uniques = {};
let indexPivot = inPivotIndicies[depth];
@ -44,6 +40,7 @@ var Pivot =
{
console.log("problem")
}
// create a set of new nodes off of the input node
inParent.Meta.Leaves.forEach((inLeaf)=>
{
let row = inLeaf.Meta.Row; // shorthand for the raw "CSV" row in the leaf Node's Meta
@ -78,7 +75,6 @@ var Pivot =
match.Leaves.push(inLeaf);
});
// get the leaves out of the parent, at this point they have been re-distributed to the children
delete inParent.Meta.Leaves;
let iterator = () => {};
if(depth >= inPivotIndicies.length-1)
@ -136,6 +132,7 @@ var Pivot =
Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1);
};
}
N.Walk(iterator, inParent, "Hierarchy");
return inParent;

View File

@ -398,13 +398,40 @@
</script>
<script>
Pivot.Create([1, 2], [3, 4]);
let pivot = N.Path([0], Pivot.Root, "Pivot");
let node = N.Path([0, 1], pivot, "Hierarchy");
Pivot.Modify(node);
Pivot.Create([2, 1], [3, 4]);
Render();
let root = N.Create("root");
let recurse = (node, depth) =>
{
// create a set of new nodes off of the input node
let c1 = N.Create(node.Meta+"-1");
let c2 = N.Create(node.Meta+"-2");
N.Connect(node, c1, "parent");
N.Connect(node, c2, "parent");
var iterator;
if(depth < 3)
{
// loop over the new nodes and keep recursing
iterator = (child) =>
{
recurse(child, depth+1);
};
}
else
{
// walk up
iterator = () =>
{
};
}
N.Walk(iterator, node, "parent", true);
}
recurse(root, 0);
</script>
</body>
</html>