2021-05-08 13:51:19 -04:00
|
|
|
|
<div id="app"></div>
|
2021-05-11 06:26:18 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
<script src="papaparse.min.js"></script>
|
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
<!-- N -->
|
2021-05-09 20:26:40 -04:00
|
|
|
|
<script>
|
|
|
|
|
var N =
|
|
|
|
|
{
|
2021-05-09 14:19:13 -04:00
|
|
|
|
ID:{
|
|
|
|
|
Walk:0,
|
|
|
|
|
Instance:0
|
|
|
|
|
},
|
2021-05-11 06:26:18 -04:00
|
|
|
|
Create(inMeta)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
{
|
2021-05-11 06:26:18 -04:00
|
|
|
|
return {
|
2021-05-09 14:19:13 -04:00
|
|
|
|
ID:{
|
|
|
|
|
Walk:0,
|
|
|
|
|
Instance:N.ID.Instance++
|
2021-05-11 06:26:18 -04:00
|
|
|
|
},
|
|
|
|
|
Meta:inMeta||{},
|
|
|
|
|
Link:{}
|
2021-05-05 21:53:04 -04:00
|
|
|
|
};
|
|
|
|
|
},
|
2021-05-14 07:11:23 -04:00
|
|
|
|
Connect(inNodeMajor, inNodeMinor, inKey, inUnique)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
{
|
2021-05-14 07:11:23 -04:00
|
|
|
|
if(inUnique) // bail if the nodes are already connected
|
|
|
|
|
{
|
|
|
|
|
let check = N.Step(inNodeMajor, inKey, true);
|
|
|
|
|
if(check)
|
|
|
|
|
{
|
2021-05-20 19:27:29 -04:00
|
|
|
|
if(check.indexOf(inNodeMinor) !== -1)
|
2021-05-14 07:11:23 -04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-11 23:18:08 -04:00
|
|
|
|
N.Step(inNodeMajor, inKey, true, true).push(inNodeMinor);
|
|
|
|
|
N.Step(inNodeMinor, inKey, false, true).push(inNodeMajor);
|
2021-05-08 07:03:41 -04:00
|
|
|
|
},
|
2021-05-09 20:26:40 -04:00
|
|
|
|
Disconnect(inNodeMajor, inNodeMinor, inKey)
|
2021-05-08 07:03:41 -04:00
|
|
|
|
{
|
2021-05-09 20:26:40 -04:00
|
|
|
|
let remove = (inArray, inMatch) => inArray.findIndex( (inMember, inIndex, inArray) => (inMember === inMatch) ? inArray.splice(inIndex, 1) : false );
|
|
|
|
|
|
2021-05-15 10:47:22 -04:00
|
|
|
|
// if no specific child was passed
|
2021-05-09 20:26:40 -04:00
|
|
|
|
if(inNodeMinor === null)
|
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
// get all the children
|
2021-05-14 07:11:23 -04:00
|
|
|
|
let check = N.Step(inNodeMajor, inKey);
|
|
|
|
|
if(!check){ return; }
|
2021-05-15 10:47:22 -04:00
|
|
|
|
|
|
|
|
|
// go down to each child ...
|
|
|
|
|
check.forEach( inNodeMinor =>
|
2021-05-09 14:19:13 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
let connections = inNodeMinor.Link[inKey];
|
|
|
|
|
remove( connections.Get, inNodeMajor); // ... and remove any reference to the parent
|
|
|
|
|
|
|
|
|
|
// if after the remove operation, this child has no connections on inKey, scrub the key
|
|
|
|
|
if(!connections.Set.length && !connections.Get.length)
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
delete inNodeMinor.Link[inKey];
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
2021-05-09 14:19:13 -04:00
|
|
|
|
});
|
2021-05-15 10:47:22 -04:00
|
|
|
|
|
|
|
|
|
// we just wiped out all outgoing connections to the parent, if incoming connections are empty too we can purge the key there as well
|
2021-05-09 20:26:40 -04:00
|
|
|
|
if(inNodeMajor.Link[inKey].Get.length == 0)
|
|
|
|
|
{
|
|
|
|
|
delete inNodeMajor.Link[inKey];
|
|
|
|
|
}
|
2021-05-09 14:19:13 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-15 10:47:22 -04:00
|
|
|
|
// if no specific parent was passed
|
2021-05-09 20:26:40 -04:00
|
|
|
|
if(inNodeMajor === null)
|
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
// get all the parents
|
|
|
|
|
let check = N.Step(inNodeMinor, inKey, false);
|
|
|
|
|
if(!check){ return; }
|
|
|
|
|
|
|
|
|
|
// go up to each parent ...
|
|
|
|
|
check.forEach( inNodeMajor =>
|
2021-05-09 14:19:13 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
let connections = inNodeMajor.Link[inKey];
|
|
|
|
|
remove( connections.Set, inNodeMinor); // ... and remove any reference to the child
|
|
|
|
|
|
|
|
|
|
// if after the remove operation, this parent has no connections on inKey, scrub the key
|
|
|
|
|
if( !connections.Set.length && !connections.Get.length )
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
delete inNodeMajor.Link[inKey];
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
2021-05-09 14:19:13 -04:00
|
|
|
|
});
|
2021-05-15 10:47:22 -04:00
|
|
|
|
|
|
|
|
|
// we just wiped out all incoming connections to the child, if outgoing connections are empty too we can purge the key there as well
|
2021-05-09 20:26:40 -04:00
|
|
|
|
if(inNodeMinor.Link[inKey].Set.length == 0)
|
|
|
|
|
{
|
|
|
|
|
delete inNodeMinor.Link[inKey];
|
|
|
|
|
}
|
2021-05-09 14:19:13 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-15 10:47:22 -04:00
|
|
|
|
// if a specific parent and child were passed
|
2021-05-09 20:26:40 -04:00
|
|
|
|
if(inNodeMajor.Link[inKey].Set.length == 1)
|
|
|
|
|
{
|
|
|
|
|
delete inNodeMajor.Link[inKey];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
remove(inNodeMajor.Link[inKey].Set, inNodeMinor);
|
|
|
|
|
}
|
|
|
|
|
if(inNodeMinor.Link[inKey].Get.length == 1)
|
|
|
|
|
{
|
|
|
|
|
delete inNodeMinor.Link[inKey];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
remove(inNodeMinor.Link[inKey].Get, inNodeMajor);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 23:18:08 -04:00
|
|
|
|
},
|
|
|
|
|
Step(inNode, inKey, inForward, inForceCreate)
|
|
|
|
|
{
|
|
|
|
|
let connectionGroup = inNode.Link[inKey];
|
|
|
|
|
if(!connectionGroup)
|
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
if(inForceCreate === true)
|
2021-05-11 23:18:08 -04:00
|
|
|
|
{
|
|
|
|
|
inNode.Link[inKey] = connectionGroup = {Get:[], Set:[]};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (inForward === undefined || inForward === true) ? connectionGroup.Set : connectionGroup.Get;
|
|
|
|
|
|
2021-05-05 21:53:04 -04:00
|
|
|
|
},
|
2021-05-15 07:30:52 -04:00
|
|
|
|
Walk(inIterator, inNode, inKey, inForward, inTerminal)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
{
|
2021-05-11 06:26:18 -04:00
|
|
|
|
let array = N.Step(inNode, inKey, inForward);
|
2021-05-15 07:30:52 -04:00
|
|
|
|
|
|
|
|
|
if(!array.length && inTerminal)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
{
|
2021-05-15 07:30:52 -04:00
|
|
|
|
return inTerminal(inNode);
|
|
|
|
|
}
|
2021-05-13 19:54:42 -04:00
|
|
|
|
|
2021-05-15 07:30:52 -04:00
|
|
|
|
for(let i=0; i<array.length; i++)
|
|
|
|
|
{
|
2021-05-05 21:53:04 -04:00
|
|
|
|
let next = array[i];
|
2021-05-09 14:19:13 -04:00
|
|
|
|
if(next.ID.Walk !== N.ID.Walk)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
{
|
2021-05-09 14:19:13 -04:00
|
|
|
|
next.ID.Walk = N.ID.Walk;
|
2021-05-28 20:52:56 -04:00
|
|
|
|
//console.log("processing", next.Meta)
|
2021-05-05 21:53:04 -04:00
|
|
|
|
let results = inIterator(next);
|
|
|
|
|
if(results !== false)
|
|
|
|
|
{
|
2021-05-15 07:30:52 -04:00
|
|
|
|
N.Walk(inIterator, next, inKey, inForward, inTerminal);
|
2021-05-05 21:53:04 -04:00
|
|
|
|
}
|
2021-05-28 20:52:56 -04:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//console.log("routine exited");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//console.log("id collision");
|
2021-05-05 21:53:04 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-11 23:18:08 -04:00
|
|
|
|
},
|
|
|
|
|
Path(inArray, inNode, inKey, inForward)
|
|
|
|
|
{
|
|
|
|
|
var current = inNode;
|
|
|
|
|
var direction = inForward||true;
|
|
|
|
|
for(let i=0; i<inArray.length; i++)
|
|
|
|
|
{
|
|
|
|
|
current = N.Step(current, inKey, direction)[inArray[i]];
|
|
|
|
|
}
|
|
|
|
|
return current;
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
|
|
|
|
};
|
2021-05-11 23:18:08 -04:00
|
|
|
|
</script>
|
2021-05-09 20:26:40 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
<!-- Pivot -->
|
2021-05-09 20:26:40 -04:00
|
|
|
|
<script>
|
|
|
|
|
var Pivot =
|
|
|
|
|
{
|
|
|
|
|
Leaves:{},
|
2021-05-15 12:52:13 -04:00
|
|
|
|
Root:N.Create({Label:"All Pivots"}),
|
2021-05-17 22:39:38 -04:00
|
|
|
|
Schema:N.Create({Label:"Column Details"}),
|
|
|
|
|
Proto:N.Create({Label:"User Form"}),
|
2021-05-29 15:25:19 -04:00
|
|
|
|
Init(inColumnTypes, inColumnNames, inRows)
|
2021-05-17 22:39:38 -04:00
|
|
|
|
{
|
|
|
|
|
for(let i=0; i<inColumnNames.length; i++)
|
|
|
|
|
{
|
2021-05-22 21:19:55 -04:00
|
|
|
|
let columnNode = N.Create({Label:inColumnNames[i], Index:i});
|
|
|
|
|
N.Connect(Pivot.Schema, columnNode, inColumnTypes[i]);
|
|
|
|
|
N.Connect(Pivot.Schema, columnNode, "all");
|
2021-05-17 22:39:38 -04:00
|
|
|
|
}
|
2021-05-29 15:25:19 -04:00
|
|
|
|
|
|
|
|
|
let numeric = (N.Step(Pivot.Schema, "sum")||[]).map(column=>column.Meta.Index);
|
|
|
|
|
console.log(numeric);
|
|
|
|
|
Pivot.Leaves = inRows.map(r =>
|
|
|
|
|
{
|
|
|
|
|
numeric.forEach(index => r[index] = parseFloat(r[index])||0);
|
|
|
|
|
return N.Create({Row:r});
|
|
|
|
|
}
|
|
|
|
|
);
|
2021-05-09 20:26:40 -04:00
|
|
|
|
Pivot.Init = ()=>{};
|
|
|
|
|
},
|
2021-05-15 12:52:13 -04:00
|
|
|
|
Pivot(inRoot, inParent, inPivotIndicies, inSumIndicies, inDepth)
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
|
|
|
|
//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 = {};
|
2021-05-28 20:52:56 -04:00
|
|
|
|
let indexPivot = inPivotIndicies[depth];
|
2021-05-09 20:26:40 -04:00
|
|
|
|
inParent.Meta.Leaves.forEach((inLeaf)=>
|
|
|
|
|
{
|
|
|
|
|
let row = inLeaf.Meta.Row; // shorthand for the raw "CSV" row in the leaf Node's Meta
|
2021-05-23 00:09:06 -04:00
|
|
|
|
let value = row[indexPivot]; // get the pivot column
|
2021-05-09 20:26:40 -04:00
|
|
|
|
let match = uniques[value]; // check in the uniques list if this pivot column exists
|
|
|
|
|
if(!match)
|
|
|
|
|
{
|
|
|
|
|
// if not, store a value under that key that will be the meta object for a new child
|
2021-05-12 19:08:52 -04:00
|
|
|
|
|
|
|
|
|
let clone = row.map(r=>null);
|
|
|
|
|
inSumIndicies.forEach((inSumIndex, inIndex, inArray)=>
|
|
|
|
|
{
|
|
|
|
|
clone[inSumIndex] = row[inSumIndex]
|
|
|
|
|
});
|
2021-05-09 20:26:40 -04:00
|
|
|
|
match = uniques[value] = {
|
|
|
|
|
Label:value,
|
2021-05-12 19:08:52 -04:00
|
|
|
|
Row:clone,
|
2021-05-23 00:09:06 -04:00
|
|
|
|
IndexPivot:indexPivot,
|
|
|
|
|
IndexSum:inSumIndicies,
|
2021-05-28 19:11:15 -04:00
|
|
|
|
Leaves:[],
|
|
|
|
|
Depth:depth
|
2021-05-09 20:26:40 -04:00
|
|
|
|
};
|
|
|
|
|
// grow a child off of the parent using the meta object
|
|
|
|
|
N.Connect(inParent, N.Create(match), "Hierarchy");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// if a match does exist, sum the appropriate columns
|
2021-05-12 19:08:52 -04:00
|
|
|
|
inSumIndicies.forEach((inSumIndex) => match.Row[inSumIndex] += row[inSumIndex]);
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
|
|
|
|
// move the leaves into the child
|
|
|
|
|
match.Leaves.push(inLeaf);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-28 20:52:56 -04:00
|
|
|
|
// get the leaves out of the parent, at this point they have been re-distributed to the children
|
2021-05-09 20:26:40 -04:00
|
|
|
|
delete inParent.Meta.Leaves;
|
2021-05-28 20:52:56 -04:00
|
|
|
|
let iterator = () => {};
|
2021-05-12 19:08:52 -04:00
|
|
|
|
if(depth >= inPivotIndicies.length-1)
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
2021-05-14 07:11:23 -04:00
|
|
|
|
iterator = inLastBranch =>
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
2021-05-14 07:11:23 -04:00
|
|
|
|
inLastBranch.Meta.Leaves.forEach( inLeaf =>
|
|
|
|
|
{
|
|
|
|
|
let modifiers = [];
|
2021-05-24 14:26:18 -04:00
|
|
|
|
let collectModifier = n => modifiers.push(n);
|
2021-05-29 15:25:19 -04:00
|
|
|
|
let connectModifiers = n => modifiers.forEach(inModifier => N.Connect(inModifier, n, "ModifyOut", true));
|
2021-05-28 20:52:56 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
// collect modifiers effecting leaves
|
2021-05-24 14:26:18 -04:00
|
|
|
|
N.Walk(collectModifier, inLeaf, "ModifyAt", false);
|
|
|
|
|
N.Walk(collectModifier, inLeaf, "ModifyDown", false);
|
2021-05-14 07:11:23 -04:00
|
|
|
|
|
|
|
|
|
if(modifiers.length)
|
|
|
|
|
{
|
|
|
|
|
// apply them to the branch
|
|
|
|
|
inLastBranch.ID.Walk = N.ID.Walk;
|
2021-05-24 14:26:18 -04:00
|
|
|
|
connectModifiers(inLastBranch);
|
2021-05-14 07:11:23 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
// also walk them up and connect to parents, but with "check unique" enabled
|
2021-05-28 20:52:56 -04:00
|
|
|
|
console.log("walking modifiers up from", inLastBranch.Meta.Label);
|
|
|
|
|
N.ID.Walk++;
|
2021-05-24 14:26:18 -04:00
|
|
|
|
N.Walk(connectModifiers, inLastBranch, "Hierarchy", false);
|
2021-05-14 07:11:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lastly connect the leaf to the branch
|
2021-05-24 11:35:06 -04:00
|
|
|
|
N.Connect(inLastBranch, inLeaf, "Leaf");
|
2021-05-28 20:52:56 -04:00
|
|
|
|
|
2021-05-14 07:11:23 -04:00
|
|
|
|
});
|
|
|
|
|
delete inLastBranch.Meta.Leaves;
|
2021-05-29 15:25:19 -04:00
|
|
|
|
return false;
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-05-28 20:52:56 -04:00
|
|
|
|
iterator = child => {
|
|
|
|
|
Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1);
|
2021-05-29 15:25:19 -04:00
|
|
|
|
return false;
|
2021-05-28 20:52:56 -04:00
|
|
|
|
};
|
2021-05-09 20:26:40 -04:00
|
|
|
|
}
|
2021-05-24 14:26:18 -04:00
|
|
|
|
N.Walk(iterator, inParent, "Hierarchy");
|
2021-05-28 20:52:56 -04:00
|
|
|
|
|
2021-05-09 20:26:40 -04:00
|
|
|
|
return inParent;
|
|
|
|
|
},
|
2021-05-29 15:25:19 -04:00
|
|
|
|
Create(inLabel, inPivotIndicies, inSumIndicies)
|
2021-05-09 20:26:40 -04:00
|
|
|
|
{
|
2021-05-14 07:11:23 -04:00
|
|
|
|
N.ID.Walk++;
|
2021-05-15 07:30:52 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
/*
|
|
|
|
|
let sumColumns = (N.Step(Pivot.Schema, "sum")||[]).map(column=>column.Meta.Index);
|
|
|
|
|
let labelColumns = (N.Step(Pivot.Schema, "label")||[]).map(column=>column.Meta.Index);
|
|
|
|
|
*/
|
2021-05-20 19:27:29 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
let pivotRoot = N.Create({Label:inLabel, Leaves:Pivot.Leaves});
|
2021-05-15 07:30:52 -04:00
|
|
|
|
N.Connect(Pivot.Root, pivotRoot, "Pivot");
|
2021-05-15 12:52:13 -04:00
|
|
|
|
return Pivot.Pivot(pivotRoot, pivotRoot, inPivotIndicies, inSumIndicies);
|
2021-05-05 21:53:04 -04:00
|
|
|
|
},
|
2021-05-15 07:30:52 -04:00
|
|
|
|
Delete(inRoot)
|
2021-05-08 07:03:41 -04:00
|
|
|
|
{
|
2021-05-15 12:52:13 -04:00
|
|
|
|
// disconnect modifiers
|
2021-05-24 11:35:06 -04:00
|
|
|
|
let check = N.Step(inRoot, "ModifyUp", false);
|
2021-05-15 10:47:22 -04:00
|
|
|
|
if(check)
|
2021-05-13 19:54:42 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
while(check.length>0)
|
|
|
|
|
{
|
|
|
|
|
Pivot.Unmodify(check[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-15 12:52:13 -04:00
|
|
|
|
|
2021-05-24 11:51:07 -04:00
|
|
|
|
// disconnect leaves from terminal branches
|
|
|
|
|
N.Walk(()=>{}, inRoot, "Hierarchy", true, terminal=>{
|
|
|
|
|
N.Disconnect(terminal, null, "Leaf");
|
2021-05-15 12:52:13 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// disconnect from app
|
2021-05-24 11:51:07 -04:00
|
|
|
|
N.Disconnect(null, inRoot, "Pivot");
|
2021-05-15 07:30:52 -04:00
|
|
|
|
},
|
|
|
|
|
Modify(inNode)
|
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
let modified = N.Create({Label:"Modifier"});
|
2021-05-20 19:27:29 -04:00
|
|
|
|
|
|
|
|
|
// traverse
|
2021-05-24 11:35:06 -04:00
|
|
|
|
let gatherUp = n => N.Connect(modified, n, "ModifyUp");
|
|
|
|
|
let gatherDown = n => N.Connect(modified, n, "ModifyDown");
|
|
|
|
|
let gatherOut = n => N.Connect(modified, n, "ModifyOut");
|
2021-05-13 19:54:42 -04:00
|
|
|
|
|
|
|
|
|
N.ID.Walk++;
|
|
|
|
|
inNode.ID.Walk = N.ID.Walk;
|
2021-05-24 11:35:06 -04:00
|
|
|
|
|
|
|
|
|
// at
|
2021-05-13 19:54:42 -04:00
|
|
|
|
N.Connect(modified, inNode, "ModifyAt");
|
2021-05-24 11:35:06 -04:00
|
|
|
|
|
|
|
|
|
// up
|
2021-05-09 14:19:13 -04:00
|
|
|
|
N.Walk(gatherUp, inNode, "Hierarchy", false);
|
2021-05-24 11:35:06 -04:00
|
|
|
|
|
|
|
|
|
// down 1
|
|
|
|
|
N.Walk(gatherDown, inNode, "Hierarchy", true, terminal=>
|
|
|
|
|
{
|
|
|
|
|
// down 2
|
|
|
|
|
// for each terminal node, step down into its leaves and gather down
|
|
|
|
|
N.Walk(gatherDown, terminal, "Leaf", true, leaf=>
|
|
|
|
|
{
|
|
|
|
|
// out 1
|
|
|
|
|
// walk back up on the leaf connections on other trees
|
|
|
|
|
N.Walk(gatherOut, leaf, "Leaf", false, terminal=>
|
|
|
|
|
{
|
|
|
|
|
// out 2
|
|
|
|
|
// and continueup the hierarchy
|
|
|
|
|
N.Walk(gatherOut, terminal, "Hierarchy", false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-05-11 23:18:08 -04:00
|
|
|
|
|
2021-05-13 19:54:42 -04:00
|
|
|
|
return modified;
|
2021-05-09 20:26:40 -04:00
|
|
|
|
},
|
2021-05-15 10:47:22 -04:00
|
|
|
|
Unmodify(inModifier)
|
2021-05-09 14:19:13 -04:00
|
|
|
|
{
|
2021-05-15 10:47:22 -04:00
|
|
|
|
N.Disconnect(inModifier, null, "ModifyUp");
|
|
|
|
|
N.Disconnect(inModifier, null, "ModifyDown");
|
|
|
|
|
N.Disconnect(inModifier, null, "ModifyOut");
|
|
|
|
|
N.Disconnect(inModifier, null, "ModifyAt");
|
|
|
|
|
N.Disconnect(null, inModifier, "Modifier");
|
2021-05-09 14:19:13 -04:00
|
|
|
|
}
|
|
|
|
|
};
|
2021-05-09 20:26:40 -04:00
|
|
|
|
</script>
|
2021-05-09 14:19:13 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
<!-- rendering -->
|
2021-05-09 20:26:40 -04:00
|
|
|
|
<script type="module">
|
2021-05-09 14:19:13 -04:00
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
/*
|
2021-05-17 22:39:38 -04:00
|
|
|
|
Pivot.Init(
|
2021-05-23 14:05:02 -04:00
|
|
|
|
["id", "type-a", "type-b", "count", "extra"],
|
2021-05-24 17:03:44 -04:00
|
|
|
|
["label", "label", "label", "sum", "sum"],
|
2021-05-17 22:39:38 -04:00
|
|
|
|
[
|
|
|
|
|
["#1", "a", "long", 1, 4],
|
|
|
|
|
["#2", "b", "long", 2, 4],
|
|
|
|
|
["#3", "b", "short", 2, 4],
|
|
|
|
|
["#4", "a", "long", 3, 4],
|
|
|
|
|
["#5", "b", "short", 1, 4],
|
|
|
|
|
["#6", "a", "short", 0, 4],
|
|
|
|
|
["#7", "b", "short", 7, 4]
|
|
|
|
|
]
|
|
|
|
|
);
|
2021-05-29 15:25:19 -04:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Papa.parse("./sample.csv",
|
|
|
|
|
{
|
|
|
|
|
download:"true",
|
|
|
|
|
complete: function(results)
|
|
|
|
|
{
|
|
|
|
|
let columnNames = results.data.shift();
|
|
|
|
|
let columnTypes = ([...columnNames]).fill("hidden");
|
|
|
|
|
|
|
|
|
|
columnTypes[29] = "sum";
|
|
|
|
|
columnTypes[30] = "sum";
|
|
|
|
|
columnTypes[31] = "sum";
|
|
|
|
|
columnTypes[32] = "sum";
|
|
|
|
|
columnTypes[33] = "sum";
|
|
|
|
|
columnTypes[7 ] = "label";
|
|
|
|
|
columnTypes[8 ] = "label";
|
|
|
|
|
columnTypes[9 ] = "label";
|
|
|
|
|
columnTypes[10] = "label";
|
|
|
|
|
columnTypes[11] = "label";
|
|
|
|
|
|
|
|
|
|
Pivot.Init(
|
|
|
|
|
columnTypes,
|
|
|
|
|
columnNames,
|
|
|
|
|
results.data
|
|
|
|
|
);
|
|
|
|
|
Render();
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-17 22:39:38 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
import { h, render, createContext, Fragment } from 'https://cdn.skypack.dev/preact';
|
|
|
|
|
import { useReducer, useState } from 'https://cdn.skypack.dev/preact/hooks';
|
|
|
|
|
import { css, cx } from 'https://cdn.skypack.dev/@emotion/css';
|
|
|
|
|
import htm from 'https://unpkg.com/htm?module';
|
|
|
|
|
const html = htm.bind(h);
|
|
|
|
|
|
|
|
|
|
let PivotForm = props =>
|
|
|
|
|
{
|
|
|
|
|
let styles = css`
|
|
|
|
|
position:realtive;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
color:black;
|
|
|
|
|
font-family:sans-serif;
|
|
|
|
|
|
|
|
|
|
.Title
|
|
|
|
|
{
|
|
|
|
|
font-size:24px;
|
|
|
|
|
font-weight:100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.Section
|
|
|
|
|
{
|
|
|
|
|
padding:10px 0 10px 0;
|
|
|
|
|
|
|
|
|
|
.Heading
|
|
|
|
|
{
|
|
|
|
|
display:inline-block;
|
|
|
|
|
color:#666;
|
|
|
|
|
font-family:sans-serif;
|
|
|
|
|
font-size:12px;
|
|
|
|
|
font-weight:900;
|
|
|
|
|
text-transform:uppercase;
|
|
|
|
|
}
|
|
|
|
|
.Group
|
|
|
|
|
{
|
|
|
|
|
display:inline-block;
|
|
|
|
|
padding:5px;
|
|
|
|
|
border-radius:5px;
|
|
|
|
|
margin:3px;
|
|
|
|
|
background:rgba(0, 0, 0, 0.3)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pivotColumns = N.Step(Pivot.Schema, "label")||[];
|
|
|
|
|
let pivotColumnsUsed = N.Step(Pivot.Proto, "used-pivot")||[];
|
|
|
|
|
|
|
|
|
|
let sumColumns = N.Step(Pivot.Schema, "sum")||[];
|
|
|
|
|
//let sumColumnsUsed = N.Step(Pivot.Proto, "used-sum")||[];
|
|
|
|
|
|
|
|
|
|
let indiciesPivot = pivotColumnsUsed.map(node=>node.Meta.Index);
|
|
|
|
|
let indiciesSum = sumColumns.map(node=>node.Meta.Index);
|
|
|
|
|
//let indiciesSum = sumColumnsUsed.map(node=>node.Meta.Index);
|
|
|
|
|
|
|
|
|
|
let displayPivotsAll = html`
|
|
|
|
|
<div class="Section">
|
|
|
|
|
<div class="Heading">Available Columns</div>
|
|
|
|
|
<div class="Group">
|
|
|
|
|
${pivotColumns.map( columnPivot =>
|
|
|
|
|
{
|
|
|
|
|
let attributes = {};
|
|
|
|
|
if(N.Step(columnPivot, "used-pivot", false))
|
|
|
|
|
{
|
|
|
|
|
attributes.disabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
attributes.onClick = e=>
|
|
|
|
|
{
|
|
|
|
|
N.Connect(Pivot.Proto, columnPivot, "used-pivot");
|
|
|
|
|
Render();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return html`<button ...${attributes}>${columnPivot.Meta.Label}</button>`;
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
let displayPivotsPending = null;
|
|
|
|
|
if(pivotColumnsUsed.length)
|
|
|
|
|
{
|
|
|
|
|
displayPivotsPending = html`
|
|
|
|
|
<div class="Section">
|
|
|
|
|
<div class="Heading">Pending Pivot</div>
|
|
|
|
|
<div class="Group">
|
|
|
|
|
${pivotColumnsUsed.map(columnPivot=>html`
|
|
|
|
|
<button onClick=${e=>{N.Disconnect(Pivot.Proto, columnPivot, "used-pivot");Render();}}>
|
|
|
|
|
${columnPivot.Meta.Label}
|
|
|
|
|
</button>
|
|
|
|
|
`)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button onClick=${e=>{
|
|
|
|
|
N.Disconnect(Pivot.Proto, null, "used-pivot");
|
|
|
|
|
N.Disconnect(Pivot.Proto, null, "used-sum");
|
2021-05-29 15:25:19 -04:00
|
|
|
|
Pivot.Create(pivotColumnsUsed.map(column=>column.Meta.Label).join("|"), indiciesPivot, indiciesSum);
|
2021-05-26 22:54:50 -04:00
|
|
|
|
Render();
|
|
|
|
|
}}>Create</button>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div class=${styles}>
|
|
|
|
|
<div class="Title">Create New Pivot</div>
|
|
|
|
|
${displayPivotsAll}
|
|
|
|
|
${displayPivotsPending}
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let Section = props =>
|
|
|
|
|
{
|
|
|
|
|
let styles = css`
|
|
|
|
|
.Heading
|
|
|
|
|
{
|
|
|
|
|
padding:6px 0 6px 0;
|
|
|
|
|
color:#666;
|
|
|
|
|
font-weight:900;
|
|
|
|
|
font-size:12px;
|
|
|
|
|
text-transform:uppercase;
|
|
|
|
|
cursor:pointer;
|
|
|
|
|
|
|
|
|
|
span
|
|
|
|
|
{
|
|
|
|
|
display:inline-block;
|
|
|
|
|
width:20px;
|
|
|
|
|
height:20px;
|
|
|
|
|
margin-right:10px;
|
|
|
|
|
border-radius:20px;
|
|
|
|
|
background:black;
|
|
|
|
|
color:white;
|
|
|
|
|
text-align:center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.Heading:hover
|
|
|
|
|
{
|
|
|
|
|
color:black;
|
|
|
|
|
}
|
|
|
|
|
.Body
|
|
|
|
|
{
|
|
|
|
|
position:relative;
|
|
|
|
|
padding:10px 0 20px 30px;
|
|
|
|
|
&::before
|
|
|
|
|
{
|
|
|
|
|
content: " ";
|
|
|
|
|
display:block;
|
|
|
|
|
position:absolute;
|
|
|
|
|
top:-8px;
|
|
|
|
|
left:8px;
|
|
|
|
|
width:3px;
|
|
|
|
|
height:100%;
|
|
|
|
|
background:black;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
let [openGet, openSet] = useState(false);
|
|
|
|
|
return html`
|
|
|
|
|
<div class=${styles}>
|
|
|
|
|
<div class="Heading" onClick=${e=>openSet(!openGet)}>
|
|
|
|
|
<span>${openGet ? `−` : `+`}</span>
|
|
|
|
|
${props.label}
|
|
|
|
|
</div>
|
|
|
|
|
${ openGet ? html`<div class="Body">${props.children}</div>` : null }
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-28 16:14:52 -04:00
|
|
|
|
let ModificationsIcon = ({node}) =>
|
|
|
|
|
{
|
2021-05-28 19:11:15 -04:00
|
|
|
|
let modsUp = N.Step(node, "ModifyUp", false)||[];
|
|
|
|
|
let modsDown = N.Step(node, "ModifyDown", false)||[];
|
|
|
|
|
let modsAt = N.Step(node, "ModifyAt", false)||[];
|
|
|
|
|
let modsOut = N.Step(node, "ModifyOut", false)||[];
|
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
var button = null;
|
|
|
|
|
if(modsAt.length)
|
|
|
|
|
{
|
|
|
|
|
button = html`<button onClick=${e=>{Pivot.Unmodify(modsAt[0]); Render();}}>-</button>`;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
button = html`<button onClick=${e=>{Pivot.Modify(node); Render();}}>+</button>`;
|
|
|
|
|
}
|
2021-05-28 16:14:52 -04:00
|
|
|
|
|
2021-05-28 19:11:15 -04:00
|
|
|
|
let padding = 7;
|
|
|
|
|
let icon = 0;
|
2021-05-28 16:14:52 -04:00
|
|
|
|
let styles = css`
|
|
|
|
|
position:relative;
|
|
|
|
|
display:inline-block;
|
2021-05-28 19:11:15 -04:00
|
|
|
|
vertical-align:middle;
|
|
|
|
|
width:${padding*2 + icon}px;
|
|
|
|
|
height:${padding*2 + icon}px;
|
2021-05-29 15:25:19 -04:00
|
|
|
|
margin:${padding*2};
|
2021-05-28 16:14:52 -04:00
|
|
|
|
.Icon
|
|
|
|
|
{
|
|
|
|
|
position:absolute;
|
|
|
|
|
display:inline-block;
|
2021-05-28 19:11:15 -04:00
|
|
|
|
width:${padding*2 + icon}px;
|
|
|
|
|
height:${padding*2 + icon}px;
|
2021-05-28 16:14:52 -04:00
|
|
|
|
text-align:center;
|
|
|
|
|
font-size:9px;
|
|
|
|
|
font-family:sans-serif;
|
|
|
|
|
font-weight:900;
|
2021-05-28 19:11:15 -04:00
|
|
|
|
line-height:${padding*2 + icon}px;
|
2021-05-28 16:14:52 -04:00
|
|
|
|
|
|
|
|
|
&::after
|
|
|
|
|
{
|
|
|
|
|
content:" ";
|
|
|
|
|
display:block;
|
|
|
|
|
position:absolute;
|
2021-05-28 19:11:15 -04:00
|
|
|
|
width:${icon}px;
|
|
|
|
|
height:${icon}px;
|
|
|
|
|
border:${padding}px solid transparent;
|
2021-05-28 16:14:52 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.Down
|
|
|
|
|
{
|
|
|
|
|
left:0;
|
|
|
|
|
bottom:100%;
|
|
|
|
|
&::after
|
|
|
|
|
{
|
|
|
|
|
top:100%;
|
|
|
|
|
border-top-color:green;
|
|
|
|
|
border-bottom:0px solid transparent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&.At
|
|
|
|
|
{
|
|
|
|
|
top:0;
|
|
|
|
|
left:100%;
|
|
|
|
|
&::after
|
|
|
|
|
{
|
|
|
|
|
top:0;
|
|
|
|
|
right:100%;
|
|
|
|
|
border-right-color:red;
|
|
|
|
|
border-left:0px solid transparent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&.Up
|
|
|
|
|
{
|
|
|
|
|
left:0;
|
|
|
|
|
top:100%;
|
|
|
|
|
&::after
|
|
|
|
|
{
|
|
|
|
|
bottom:100%;
|
|
|
|
|
border-bottom-color:orange;
|
|
|
|
|
border-top:0px solid transparent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.Out
|
|
|
|
|
{
|
|
|
|
|
top:0;
|
|
|
|
|
right:100%;
|
|
|
|
|
&::after
|
|
|
|
|
{
|
|
|
|
|
top:0;
|
|
|
|
|
left:100%;
|
|
|
|
|
border-left-color:grey;
|
|
|
|
|
border-right:0px solid transparent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
return html`
|
2021-05-28 19:11:15 -04:00
|
|
|
|
<div class=${styles}>
|
2021-05-28 16:14:52 -04:00
|
|
|
|
${modsDown.length ? html`<div class="Icon Down">${modsDown.length}</div>` : null}
|
|
|
|
|
${modsAt.length ? html`<span class="Icon At">${modsAt.length}</span>` : null}
|
|
|
|
|
${modsUp.length ? html`<span class="Icon Up">${modsUp.length}</span>` : null}
|
|
|
|
|
${modsOut.length ? html`<span class="Icon Out">${modsOut.length}</span>` : null}
|
|
|
|
|
</div>
|
2021-05-29 15:25:19 -04:00
|
|
|
|
${button}
|
2021-05-28 16:14:52 -04:00
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
let PivotBranch = props =>
|
|
|
|
|
{
|
|
|
|
|
let row = props.node.Meta.Row;
|
|
|
|
|
let displayCellsModify = row.map(column=>false);
|
|
|
|
|
props.node.Meta.IndexSum.forEach(i=>
|
|
|
|
|
{
|
|
|
|
|
displayCellsModify[i] = html`<td><input type="number" value=${row[i]}/></td>`;
|
|
|
|
|
});
|
|
|
|
|
displayCellsModify.forEach((cell, i)=>
|
|
|
|
|
{
|
|
|
|
|
if(!cell)
|
|
|
|
|
{
|
|
|
|
|
displayCellsModify[i] = html`<td>${row[i]}</td>`
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-29 16:04:38 -04:00
|
|
|
|
let displayCells = (node, visible) =>
|
|
|
|
|
{
|
|
|
|
|
let output = [];
|
|
|
|
|
node.Meta.Row.forEach((column, i)=>
|
|
|
|
|
{
|
|
|
|
|
if(visible[i])
|
|
|
|
|
{
|
|
|
|
|
output.push( h("td", null, column) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-29 15:25:19 -04:00
|
|
|
|
let stylesLeaf = css`
|
|
|
|
|
background:#ddd;
|
|
|
|
|
color:#333;
|
|
|
|
|
`;
|
2021-05-28 19:11:15 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
return html`
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td>
|
2021-05-28 19:11:15 -04:00
|
|
|
|
<strong class=${css`margin-left:${props.node.Meta.Depth*10}px;`}>${props.node.Meta.Label}</strong>
|
2021-05-29 15:25:19 -04:00
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
<${ModificationsIcon} node=${props.node}><//>
|
2021-05-26 22:54:50 -04:00
|
|
|
|
</td>
|
2021-05-29 16:04:38 -04:00
|
|
|
|
${displayCells(props.node, props.visible)}
|
2021-05-26 22:54:50 -04:00
|
|
|
|
</tr>
|
2021-05-29 15:25:19 -04:00
|
|
|
|
${(N.Step(props.node, "Leaf")||[]).map(leaf =>
|
|
|
|
|
{
|
|
|
|
|
return html`
|
|
|
|
|
<tr class=${stylesLeaf}>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td><${ModificationsIcon} node=${leaf}><//></td>
|
2021-05-29 16:04:38 -04:00
|
|
|
|
${displayCells(leaf, props.visible)}
|
2021-05-29 15:25:19 -04:00
|
|
|
|
</tr>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
)}
|
2021-05-26 22:54:50 -04:00
|
|
|
|
</tbody>
|
|
|
|
|
`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let PivotRoot = ({pivot}) =>
|
|
|
|
|
{
|
2021-05-29 16:55:02 -04:00
|
|
|
|
let labelsDefault = (N.Step(Pivot.Schema, "hidden")||[]).map(column => column.Meta.Index);
|
|
|
|
|
let labelsSum = (N.Step(Pivot.Schema, "sum")||[]).map(column => column.Meta.Index);
|
|
|
|
|
let labelsPivot = (N.Step(Pivot.Schema, "label")||[]).map(column => column.Meta.Index);
|
|
|
|
|
let labelsAll = (N.Step(Pivot.Schema, "all")||[]).map(column => column.Meta.Label);
|
|
|
|
|
let labelsAllState = useState(labelsAll.map(column=>true));
|
|
|
|
|
|
|
|
|
|
let headersDisplay = [];
|
|
|
|
|
labelsAllState[0].forEach((visible, index)=>
|
|
|
|
|
{
|
|
|
|
|
if(visible)
|
|
|
|
|
{
|
|
|
|
|
headersDisplay.push(html`<th>${labelsAll[index]}</th>`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2021-05-29 16:04:38 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
let stylesRoot = css`
|
|
|
|
|
display:block;
|
|
|
|
|
box-sizing:border-box;
|
|
|
|
|
padding:15px;
|
|
|
|
|
font-family:sans-serif;
|
|
|
|
|
`;
|
|
|
|
|
let stylesHeading = css`
|
|
|
|
|
margin: 0 0 15px 0;
|
|
|
|
|
font-weight:0;
|
|
|
|
|
font-size:24px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
let modifiers = N.Step(pivot, "ModifyUp", false) || [];
|
|
|
|
|
let handleDelete = ()=>
|
|
|
|
|
{
|
|
|
|
|
Pivot.Delete(pivot);
|
|
|
|
|
Render();
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-29 16:55:02 -04:00
|
|
|
|
|
|
|
|
|
let displayColumnGroup = (inAllLabels, inAllState, inIndicies) =>
|
|
|
|
|
{
|
|
|
|
|
return html`
|
|
|
|
|
<div>
|
|
|
|
|
<button onClick=${e=>
|
|
|
|
|
{
|
|
|
|
|
let clone = [...inAllState[0]];
|
|
|
|
|
inIndicies.forEach(index =>clone[index] = true);
|
|
|
|
|
inAllState[1](clone);
|
|
|
|
|
}
|
|
|
|
|
}>Show All</button>
|
|
|
|
|
<button onClick=${e=>
|
|
|
|
|
{
|
|
|
|
|
let clone = [...inAllState[0]];
|
|
|
|
|
inIndicies.forEach(index =>clone[index] = false);
|
|
|
|
|
inAllState[1](clone);
|
|
|
|
|
}
|
|
|
|
|
}>Hide All</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
${inIndicies.map((index) => html`<button onClick=${e=>
|
|
|
|
|
{
|
|
|
|
|
let clone = [...inAllState[0]];
|
|
|
|
|
clone[index] = !clone[index];
|
|
|
|
|
inAllState[1](clone);
|
|
|
|
|
}
|
|
|
|
|
}>${inAllLabels[index]} ${inAllState[0][index] ? `visible`:`hidden`}</button>`)}
|
|
|
|
|
</div>`;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
let rows = [];
|
|
|
|
|
N.ID.Walk++;
|
2021-05-29 16:55:02 -04:00
|
|
|
|
N.Walk(n=>rows.push(h(PivotBranch, {node:n, visible:labelsAllState[0]}, null)), pivot, "Hierarchy");
|
2021-05-26 22:54:50 -04:00
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div class=${stylesRoot}>
|
|
|
|
|
<div key="heading" class=${stylesHeading}>${pivot.Meta.Label}</div>
|
|
|
|
|
<${Section} key="settings" label=${`Settings`}>
|
|
|
|
|
<button onClick=${handleDelete}>Destroy Pivot</button>
|
2021-05-29 16:55:02 -04:00
|
|
|
|
<//>
|
|
|
|
|
<${Section} key="columns" label="Columns">
|
|
|
|
|
<h3>Unused</h3>
|
|
|
|
|
${displayColumnGroup(labelsAll, labelsAllState, labelsDefault)}
|
|
|
|
|
<h3>Summation</h3>
|
|
|
|
|
${displayColumnGroup(labelsAll, labelsAllState, labelsSum)}
|
|
|
|
|
<h3>Pivot</h3>
|
|
|
|
|
${displayColumnGroup(labelsAll, labelsAllState, labelsPivot)}
|
2021-05-26 22:54:50 -04:00
|
|
|
|
<//>
|
|
|
|
|
<${Section} key="tree" label=${"Tree"}>
|
|
|
|
|
<table>
|
2021-05-29 16:55:02 -04:00
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Label</th><th>Modifications</th>${headersDisplay}
|
|
|
|
|
</th>
|
|
|
|
|
</thead>
|
|
|
|
|
${rows}
|
2021-05-26 22:54:50 -04:00
|
|
|
|
</table>
|
|
|
|
|
<//>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-14 06:47:30 -04:00
|
|
|
|
let ElRoot = props =>
|
2021-05-08 13:51:19 -04:00
|
|
|
|
{
|
2021-05-15 12:52:13 -04:00
|
|
|
|
let pivots = N.Step(Pivot.Root, "Pivot")||[];
|
2021-05-13 19:54:42 -04:00
|
|
|
|
return h("div", null, [
|
2021-05-23 14:05:02 -04:00
|
|
|
|
h(PivotForm),
|
2021-05-24 22:52:55 -04:00
|
|
|
|
pivots.map(pivot=>h(PivotRoot, {key:pivot.Meta.Label, pivot}))
|
2021-05-13 19:54:42 -04:00
|
|
|
|
])
|
2021-05-08 13:51:19 -04:00
|
|
|
|
};
|
2021-05-26 22:54:50 -04:00
|
|
|
|
const Render = () => render(h(ElRoot), document.querySelector("#app"));
|
2021-05-14 06:47:30 -04:00
|
|
|
|
Render();
|
2021-05-08 13:51:19 -04:00
|
|
|
|
|
2021-05-26 22:54:50 -04:00
|
|
|
|
</script>
|
|
|
|
|
|