From d855e86706a98cff93f0d3363c2187c650908b39 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Sat, 15 May 2021 12:52:13 -0400 Subject: [PATCH 1/4] pivot deletion working --- index.html | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 6ebb739..541ba45 100755 --- a/index.html +++ b/index.html @@ -172,14 +172,14 @@ var N = var Pivot = { Leaves:{}, - Root:N.Create({}), + Root:N.Create({Label:"All Pivots"}), Init(inRows) { Pivot.Leaves = inRows.map(r => N.Create({Row:r})); Pivot.Init = ()=>{}; }, - Pivot(inParent, inPivotIndicies, inSumIndicies, inDepth) + Pivot(inRoot, inParent, inPivotIndicies, inSumIndicies, inDepth) { //arguments: // - a Node with leaf Nodes temporarily stored in its Meta.Leaves @@ -226,6 +226,7 @@ var Pivot = { iterator = inLastBranch => { + N.Connect(inRoot, inLastBranch, "Terminal"); inLastBranch.Meta.Leaves.forEach( inLeaf => { // collect modifiers effecting leaves @@ -247,7 +248,7 @@ var Pivot = inLastBranch.ID.Walk = N.ID.Walk; modifiers.forEach( inModifier => N.Connect(inModifier, inLastBranch, "ModifyUp") ) - // also walk them up, but with a unique check connection + // also walk them up and connect, but with "check unique" enabled N.Walk( inNode=> { modifiers.forEach( inModifier => N.Connect(inModifier, inNode, "ModifyUp", true) ) @@ -263,7 +264,7 @@ var Pivot = } else { - iterator = child => Pivot.Pivot(child, inPivotIndicies, inSumIndicies, depth+1); + iterator = child => Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1); } N.Step(inParent, "Hierarchy").forEach(iterator); return inParent; @@ -274,10 +275,11 @@ var Pivot = let pivotRoot = N.Create({Label:"Pivot Root", Leaves:Pivot.Leaves}); N.Connect(Pivot.Root, pivotRoot, "Pivot"); - return Pivot.Pivot(pivotRoot, inPivotIndicies, inSumIndicies); + return Pivot.Pivot(pivotRoot, pivotRoot, inPivotIndicies, inSumIndicies); }, Delete(inRoot) { + // disconnect modifiers let check = N.Step(inRoot, "Modifier"); if(check) { @@ -286,6 +288,14 @@ var Pivot = Pivot.Unmodify(check[0]); } } + + // disconnect terminal branches + N.Walk(()=>{}, inRoot, "Terminal", inNode=>{ + N.Disconnect(inNode, null, "Hierarchy"); + }); + + // disconnect from app + N.Disconnect(null, inRoot, "Pivot") }, Modify(inNode) { @@ -461,6 +471,7 @@ let ElModifiers = ({node}) => }; let ElRoot = props => { + let pivots = N.Step(Pivot.Root, "Pivot")||[]; return h("div", null, [ h("h3", null, "tree view"), h(ElModifiers, {node:Pivot.Root}), @@ -469,7 +480,7 @@ let ElRoot = props => AddNewPivot(); } }, "add new pivot"), - ...N.Step(Pivot.Root, "Pivot").map(pivot=>h(ElPivot, {pivot})) + pivots.map(pivot=>h(ElPivot, {pivot})) ]) }; let Render = () => render(h(ElRoot), document.querySelector("#app")); From ae22e995f27aaf4cfc107a6a778cb3ffb7c62ced Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Mon, 17 May 2021 22:39:38 -0400 Subject: [PATCH 2/4] pivot builder node-based, ElForm needs clean up --- index.html | 100 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/index.html b/index.html index 541ba45..b7ecf28 100755 --- a/index.html +++ b/index.html @@ -173,9 +173,14 @@ var Pivot = { Leaves:{}, Root:N.Create({Label:"All Pivots"}), - - Init(inRows) - { + Schema:N.Create({Label:"Column Details"}), + Proto:N.Create({Label:"User Form"}), + Init(inColumnNames, inColumnTypes, inRows) + { + for(let i=0; i N.Create({Row:r})); Pivot.Init = ()=>{}; }, @@ -349,21 +354,76 @@ import { h, render, createContext, Fragment } from 'https://cdn.skypack.dev/prea import { useReducer } from 'https://cdn.skypack.dev/preact/hooks'; import { css, cx } from 'https://cdn.skypack.dev/@emotion/css'; -Pivot.Init([ - ["#1", "a", "long", 1], - ["#2", "b", "long", 2], - ["#3", "b", "short", 2], - ["#4", "a", "long", 3], - ["#5", "b", "short", 1], - ["#6", "a", "short", 0], - ["#7", "b", "short", 7], -]); -Pivot.Create([1, 2], [3]); +Pivot.Init( + ["number", "type-a", "type-b", "count"], + ["label", "label", "label", "sum"], + [ + ["#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] + ] +); -let AddNewPivot = () => +let ElForm = props => { - Pivot.Create([2], [3]); - Render(); + let labelColumns = N.Step(Pivot.Schema, "label")||[]; + + let used = N.Step(Pivot.Proto, "used")||[]; + let unused = N.Step(Pivot.Schema, "label").filter( columnLabel => !N.Step(columnLabel, "used", false) ); + let indicies = used.map(node=>node.Meta.Index); + + var action; + if(indicies.length) + { + action = h("div", null, [ + h("span", null, "Build"), + h("button", {onClick:e=> + { + N.Disconnect(Pivot.Proto, null, "used"); + Pivot.Create(indicies, [3, 4]); + Render(); + } + }, indicies) + ]); + } + else + { + action = h("div", null, "(select columns)") + } + + return h("div", {}, [ + h("div", null, [ + h("span", null, "available"), + ...unused.map( node=> + { + return h("button", {onClick:e=> + { + N.Connect(Pivot.Proto, node, "used"); + Render(); + } + }, node.Meta.Label); + } + ) + ]), + h("div", null, [ + h("span", null, "taken"), + ...used.map( node=> + { + return h("button", {onClick:e=> + { + N.Disconnect(Pivot.Proto, node, "used"); + Render(); + } + }, node.Meta.Label); + } + ) + ]), + action + ]) }; let ElNode = ({node, depth}) => @@ -449,7 +509,7 @@ let ElNode = ({node, depth}) => }; let ElPivot = ({pivot}) => { - return h("div", {style:{display:"inline-block", width:"500px"}}, [ + return h("div", {style:{display:"inline-block", width:"800px"}}, [ h("button", {onClick:e=>{Pivot.Delete(pivot);Render();}}, "delete?"), h(ElModifiers, {node:pivot}), h(ElNode, {node:pivot, depth:0}) @@ -474,12 +534,8 @@ let ElRoot = props => let pivots = N.Step(Pivot.Root, "Pivot")||[]; return h("div", null, [ h("h3", null, "tree view"), + h(ElForm), h(ElModifiers, {node:Pivot.Root}), - h("button", { onClick:e=> - { - AddNewPivot(); - } - }, "add new pivot"), pivots.map(pivot=>h(ElPivot, {pivot})) ]) }; From a516f7b3d6482c9b4f3c0345d9c640b2a88c10d3 Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Thu, 20 May 2021 19:27:29 -0400 Subject: [PATCH 3/4] fixed modify out issue --- index.html | 27 ++++++++++++++++++++------- save.json | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 save.json diff --git a/index.html b/index.html index b7ecf28..b90b398 100755 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@ var N = let check = N.Step(inNodeMajor, inKey, true); if(check) { - if(check.indexOf(inNodeMinor) < 0) + if(check.indexOf(inNodeMinor) !== -1) { return; } @@ -251,12 +251,12 @@ var Pivot = { // apply them to the branch inLastBranch.ID.Walk = N.ID.Walk; - modifiers.forEach( inModifier => N.Connect(inModifier, inLastBranch, "ModifyUp") ) + modifiers.forEach( inModifier => N.Connect(inModifier, inLastBranch, "ModifyOut") ) // also walk them up and connect, but with "check unique" enabled N.Walk( inNode=> { - modifiers.forEach( inModifier => N.Connect(inModifier, inNode, "ModifyUp", true) ) + modifiers.forEach( inModifier => N.Connect(inModifier, inNode, "ModifyOut", true) ) } , inLastBranch, "Hierarchy", false); } @@ -278,7 +278,13 @@ var Pivot = { N.ID.Walk++; - let pivotRoot = N.Create({Label:"Pivot Root", Leaves:Pivot.Leaves}); + let names = N.Step(Pivot.Schema, "label"); + let label = inPivotIndicies.map( inPivotIndex => + { + return names[inPivotIndex].Meta.Label; + }); + + let pivotRoot = N.Create({Label:label.join("|"), Leaves:Pivot.Leaves}); N.Connect(Pivot.Root, pivotRoot, "Pivot"); return Pivot.Pivot(pivotRoot, pivotRoot, inPivotIndicies, inSumIndicies); }, @@ -305,6 +311,8 @@ var Pivot = Modify(inNode) { let modified = N.Create({Label:"Modifier"}); + + // add the modifier to the appropriate root N.ID.Walk++; if(N.Step(inNode, "Hierarchy").length) { @@ -318,6 +326,7 @@ var Pivot = N.Connect(Pivot.Root, modified, "Modifier"); } + // traverse let leaves = []; let gatherUp = n => N.Connect(modified, n, "ModifyUp"); let gatherDown = n => @@ -325,7 +334,11 @@ var Pivot = N.Connect(modified, n, "ModifyDown"); N.Step(n, "Hierarchy").length == 0 ? leaves.push(n) : null; }; - let gatherOut = n => N.Connect(modified, n, "ModifyOut"); + let gatherOut = n => { + + N.Connect(modified, n, "ModifyOut"); + + }; N.ID.Walk++; inNode.ID.Walk = N.ID.Walk; @@ -425,7 +438,6 @@ let ElForm = props => action ]) }; - let ElNode = ({node, depth}) => { let nodeBase = css` @@ -509,7 +521,8 @@ let ElNode = ({node, depth}) => }; let ElPivot = ({pivot}) => { - return h("div", {style:{display:"inline-block", width:"800px"}}, [ + return h("div", {className:css`display:inline-block;`}, [ + h("h3", null, pivot.Meta.Label), h("button", {onClick:e=>{Pivot.Delete(pivot);Render();}}, "delete?"), h(ElModifiers, {node:pivot}), h(ElNode, {node:pivot, depth:0}) diff --git a/save.json b/save.json new file mode 100644 index 0000000..1849b6e --- /dev/null +++ b/save.json @@ -0,0 +1,20 @@ +[ + { + "name":"", + "csv":["data/output/1.csv", "data/output/2.csv"], + "pivots": + [ + { + "pivot":[0, 1], + "sum":[3], + "modifications": + [ + { + "path":[0, 0], + "modification":[0.2] + } + ] + } + ] + } +] \ No newline at end of file From 90c7d35ac39e8d0552bea68a035aeec25e7ce4cc Mon Sep 17 00:00:00 2001 From: TreetopFlyer Date: Thu, 20 May 2021 19:29:35 -0400 Subject: [PATCH 4/4] project file example --- save.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/save.json b/save.json index 1849b6e..0ecad77 100644 --- a/save.json +++ b/save.json @@ -1,20 +1,20 @@ -[ - { - "name":"", - "csv":["data/output/1.csv", "data/output/2.csv"], - "pivots": - [ - { - "pivot":[0, 1], - "sum":[3], - "modifications": - [ - { - "path":[0, 0], - "modification":[0.2] - } - ] - } - ] - } +[ + { + "name":"", + "csv":["data/output/1.csv", "data/output/2.csv"], + "pivots": + [ + { + "pivot":[0, 1], + "sum":[3], + "modifications": + [ + { + "path":[0, 0], + "modification":[0.2] + } + ] + } + ] + } ] \ No newline at end of file