Compare commits
No commits in common. "3a8fecf55f211fa61371b2572a2f68b19db476f9" and "490019a27ba6722b8c04521e9fcf665637e0d36a" have entirely different histories.
3a8fecf55f
...
490019a27b
96
index.html
96
index.html
@ -196,11 +196,10 @@ var Pivot =
|
||||
// - optional traversal depth, defaults to 0
|
||||
let depth = inDepth||0;
|
||||
let uniques = {};
|
||||
let indexPivot = inPivotIndicies[depth]
|
||||
inParent.Meta.Leaves.forEach((inLeaf)=>
|
||||
{
|
||||
let row = inLeaf.Meta.Row; // shorthand for the raw "CSV" row in the leaf Node's Meta
|
||||
let value = row[indexPivot]; // get the pivot column
|
||||
let value = row[inPivotIndicies[depth]]; // get the pivot column
|
||||
let match = uniques[value]; // check in the uniques list if this pivot column exists
|
||||
if(!match)
|
||||
{
|
||||
@ -214,8 +213,6 @@ var Pivot =
|
||||
match = uniques[value] = {
|
||||
Label:value,
|
||||
Row:clone,
|
||||
IndexPivot:indexPivot,
|
||||
IndexSum:inSumIndicies,
|
||||
Leaves:[]
|
||||
};
|
||||
// grow a child off of the parent using the meta object
|
||||
@ -373,8 +370,8 @@ import { useReducer } from 'https://cdn.skypack.dev/preact/hooks';
|
||||
import { css, cx } from 'https://cdn.skypack.dev/@emotion/css';
|
||||
|
||||
Pivot.Init(
|
||||
["number", "type-a", "type-b", "count", "extra"],
|
||||
["label", "label", "label", "sum", "sum"],
|
||||
["number", "type-a", "type-b", "count"],
|
||||
["label", "label", "label", "sum"],
|
||||
[
|
||||
["#1", "a", "long", 1, 4],
|
||||
["#2", "b", "long", 2, 4],
|
||||
@ -388,24 +385,21 @@ Pivot.Init(
|
||||
|
||||
let ElForm = props =>
|
||||
{
|
||||
let pivotColumns = N.Step(Pivot.Schema, "label")||[];
|
||||
let pivotColumnsUsed = N.Step(Pivot.Proto, "used-pivot")||[];
|
||||
let labelColumns = N.Step(Pivot.Schema, "label")||[];
|
||||
|
||||
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 = sumColumnsUsed.map(node=>node.Meta.Index);
|
||||
let used = N.Step(Pivot.Proto, "used")||[];
|
||||
let unused = N.Step(Pivot.Schema, "label").filter( columnLabel => !N.Step(columnLabel, "used", false) );
|
||||
let indiciesPivot = used.map(node=>node.Meta.Index);
|
||||
let indiciesSum = (N.Step(Pivot.Schema, "sum")||[]).map(n=>n.Meta.Index);
|
||||
|
||||
var action;
|
||||
if(indiciesPivot.length)
|
||||
{
|
||||
action = h("p", null, [
|
||||
action = h("div", null, [
|
||||
h("span", null, "Build"),
|
||||
h("button", {onClick:e=>
|
||||
{
|
||||
N.Disconnect(Pivot.Proto, null, "used-pivot");
|
||||
N.Disconnect(Pivot.Proto, null, "used-sum");
|
||||
N.Disconnect(Pivot.Proto, null, "used");
|
||||
Pivot.Create(indiciesPivot, indiciesSum);
|
||||
Render();
|
||||
}
|
||||
@ -414,71 +408,35 @@ let ElForm = props =>
|
||||
}
|
||||
else
|
||||
{
|
||||
action = h("p", null, "(select columns)")
|
||||
action = h("div", null, "(select columns)")
|
||||
}
|
||||
|
||||
return h("div", {}, [
|
||||
h("p", null, [
|
||||
|
||||
h("span", null, "Pivot Columns"),
|
||||
...pivotColumns.map( columnLabel =>
|
||||
h("div", null, [
|
||||
h("span", null, "available"),
|
||||
...unused.map( node=>
|
||||
{
|
||||
let attributes = {};
|
||||
if(N.Step(columnLabel, "used-pivot", false))
|
||||
return h("button", {onClick:e=>
|
||||
{
|
||||
attributes.disabled = true;
|
||||
N.Connect(Pivot.Proto, node, "used");
|
||||
Render();
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.onClick = e=>
|
||||
{
|
||||
N.Connect(Pivot.Proto, columnLabel, "used-pivot");
|
||||
Render();
|
||||
}
|
||||
}
|
||||
return h("button", attributes, columnLabel.Meta.Label);
|
||||
}),
|
||||
|
||||
h("span", null, "Summation Columns"),
|
||||
...sumColumns.map( columnSum =>
|
||||
{
|
||||
let attributes = {};
|
||||
if(N.Step(columnSum, "used-sum", false))
|
||||
{
|
||||
attributes.disabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.onClick = e=>
|
||||
{
|
||||
N.Connect(Pivot.Proto, columnSum, "used-sum");
|
||||
Render();
|
||||
}
|
||||
}
|
||||
return h("button", attributes, columnSum.Meta.Label);
|
||||
})
|
||||
}, node.Meta.Label);
|
||||
}
|
||||
)
|
||||
]),
|
||||
h("p", null, [
|
||||
h("span", null, "Current Pivot"),
|
||||
...pivotColumnsUsed.map( columnLabel =>
|
||||
h("div", null, [
|
||||
h("span", null, "taken"),
|
||||
...used.map( node=>
|
||||
{
|
||||
return h("button", {onClick:e=>
|
||||
{
|
||||
N.Disconnect(Pivot.Proto, columnLabel, "used-pivot");
|
||||
N.Disconnect(Pivot.Proto, node, "used");
|
||||
Render();
|
||||
}
|
||||
}, columnLabel.Meta.Label);
|
||||
}),
|
||||
h("span", null, "Current Summation"),
|
||||
...sumColumnsUsed.map( columnSum =>
|
||||
{
|
||||
return h("button", {onClick:e=>
|
||||
{
|
||||
N.Disconnect(Pivot.Proto, columnSum, "used-sum");
|
||||
Render();
|
||||
}
|
||||
}, columnSum.Meta.Label);
|
||||
}),
|
||||
}, node.Meta.Label);
|
||||
}
|
||||
)
|
||||
]),
|
||||
action
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user