Skip to content

Commit

Permalink
Pass x and y axes as single object
Browse files Browse the repository at this point in the history
  • Loading branch information
David Mesquita-Morris committed Sep 26, 2021
1 parent 902c870 commit 3e2750d
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 85 deletions.
30 changes: 9 additions & 21 deletions docs/api/v3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h3>merge</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L84">index.ts:84</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L82">index.ts:82</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -126,13 +126,13 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</spa
<a name="split" class="tsd-anchor"></a>
<h3>split</h3>
<ul class="tsd-signatures tsd-kind-function tsd-has-type-parameter">
<li class="tsd-signature tsd-kind-icon">split&lt;TRow&gt;<span class="tsd-signature-symbol">(</span>keys<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Cube</span><span class="tsd-signature-symbol">&lt;</span><a href="interfaces/key.html" class="tsd-signature-type" data-tsd-kind="Interface">Key</a><span class="tsd-signature-symbol">&gt;</span>, x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, onX<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="interfaces/cell.html" class="tsd-signature-type" data-tsd-kind="Interface">Cell</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></li>
<li class="tsd-signature tsd-kind-icon">split&lt;TRow&gt;<span class="tsd-signature-symbol">(</span>keys<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Cube</span><span class="tsd-signature-symbol">&lt;</span><a href="interfaces/key.html" class="tsd-signature-type" data-tsd-kind="Interface">Key</a><span class="tsd-signature-symbol">&gt;</span>, axes<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Axes</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, onX<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="interfaces/cell.html" class="tsd-signature-type" data-tsd-kind="Interface">Cell</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L46">index.ts:46</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L44">index.ts:44</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -152,15 +152,9 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>keys: <span class="tsd-signature-type">Cube</span><span class="tsd-signature-symbol">&lt;</span><a href="interfaces/key.html" class="tsd-signature-type" data-tsd-kind="Interface">Key</a><span class="tsd-signature-symbol">&gt;</span></h5>
</li>
<li>
<h5>x: <span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<h5>axes: <span class="tsd-signature-type">Axes</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<div class="tsd-comment tsd-typography">
<p>The dimension used as the x axis.</p>
</div>
</li>
<li>
<h5>y: <span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<div class="tsd-comment tsd-typography">
<p>The dimension used as the y axis.</p>
<p>The x and y axes used in the pivot operation to create the cube.</p>
</div>
</li>
<li>
Expand All @@ -178,13 +172,13 @@ <h4 class="tsd-returns-title">Returns <a href="interfaces/cell.html" class="tsd-
<a name="table" class="tsd-anchor"></a>
<h3>table</h3>
<ul class="tsd-signatures tsd-kind-function tsd-has-type-parameter">
<li class="tsd-signature tsd-kind-icon">table&lt;TRow&gt;<span class="tsd-signature-symbol">(</span>cube<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Cube</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, y<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, getKey<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func1</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">, </span><a href="interfaces/key.html" class="tsd-signature-type" data-tsd-kind="Interface">Key</a><span class="tsd-signature-symbol">&gt;</span>, onX<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="interfaces/cell.html" class="tsd-signature-type" data-tsd-kind="Interface">Cell</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></li>
<li class="tsd-signature tsd-kind-icon">table&lt;TRow&gt;<span class="tsd-signature-symbol">(</span>cube<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Cube</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, axes<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Axes</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span>, getKey<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Func1</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">, </span><a href="interfaces/key.html" class="tsd-signature-type" data-tsd-kind="Interface">Key</a><span class="tsd-signature-symbol">&gt;</span>, onX<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="interfaces/cell.html" class="tsd-signature-type" data-tsd-kind="Interface">Cell</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L31">index.ts:31</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L30">index.ts:30</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -207,15 +201,9 @@ <h5>cube: <span class="tsd-signature-type">Cube</span><span class="tsd-signature
</div>
</li>
<li>
<h5>x: <span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<div class="tsd-comment tsd-typography">
<p>The dimension used as the x axis.</p>
</div>
</li>
<li>
<h5>y: <span class="tsd-signature-type">Dimension</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<h5>axes: <span class="tsd-signature-type">Axes</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TRow</span><span class="tsd-signature-symbol">&gt;</span></h5>
<div class="tsd-comment tsd-typography">
<p>The dimension used as the y axis.</p>
<p>The x and y axes used in the pivot operation to create the cube.</p>
</div>
</li>
<li>
Expand Down
8 changes: 4 additions & 4 deletions docs/api/v3/interfaces/cell.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h3>cols</h3>
<div class="tsd-signature tsd-kind-icon">cols<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L20">index.ts:20</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L20">index.ts:20</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -122,7 +122,7 @@ <h3>rows</h3>
<div class="tsd-signature tsd-kind-icon">rows<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L17">index.ts:17</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L17">index.ts:17</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -138,7 +138,7 @@ <h3>style</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="key.html">Key</a>.<a href="key.html#style">style</a></p>
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L11">index.ts:11</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L11">index.ts:11</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -154,7 +154,7 @@ <h3>text</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="key.html">Key</a>.<a href="key.html#text">text</a></p>
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L8">index.ts:8</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L8">index.ts:8</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
4 changes: 2 additions & 2 deletions docs/api/v3/interfaces/key.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h3>style</h3>
<div class="tsd-signature tsd-kind-icon">style<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L11">index.ts:11</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L11">index.ts:11</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -120,7 +120,7 @@ <h3>text</h3>
<div class="tsd-signature tsd-kind-icon">text<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/99d3856/src/index.ts#L8">index.ts:8</a></li>
<li>Defined in <a href="https://github.com/steelbreeze/landscape/blob/902c870/src/index.ts#L8">index.ts:8</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/landscape.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions docs/dynamic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,16 @@ <h4>Social</h4>
</article>
</section>
</footer>
<!--script src="../dist/landscape.min.js"></script-->
<script src="../dist/landscape.min.js"></script>
<script type="module">
import * as d3 from 'https://cdn.skypack.dev/d3-dsv?min';
import * as pivot from 'https://cdn.skypack.dev/@steelbreeze/pivot?min';
import * as landscape from 'https://cdn.skypack.dev/@steelbreeze/landscape?min';
import * as pivot from 'https://cdn.skypack.dev/@steelbreeze/pivot';

const context = {
file: undefined,
json: undefined,
dimensions: undefined,
xAxis: undefined,
yAxis: undefined,
axes: undefined,
cube: undefined,
getKey: undefined
};
Expand Down Expand Up @@ -403,14 +401,16 @@ <h4>Social</h4>
}

function pivotAndRender() {
context.xAxis = xAxisPicker.selectedIndex ? pivot.deriveDimension(context.json, xAxisPicker.value, { sort: sortBy(xAxisPicker.value) }) : pivot.dimension(['Select x-axis'], 'noX', () => 'Select x-axis');
context.yAxis = yAxisPicker.selectedIndex ? pivot.deriveDimension(context.json, yAxisPicker.value, { sort: sortBy(xAxisPicker.value) }) : pivot.dimension(['Select y-axis'], 'noX', () => 'Select y-axis');
context.axes = {
x: xAxisPicker.selectedIndex ? pivot.deriveDimension(context.json, xAxisPicker.value, { sort: sortBy(xAxisPicker.value) }) : pivot.dimension(['Select x-axis'], 'noX', () => 'Select x-axis'),
y: yAxisPicker.selectedIndex ? pivot.deriveDimension(context.json, yAxisPicker.value, { sort: sortBy(xAxisPicker.value) }) : pivot.dimension(['Select y-axis'], 'noX', () => 'Select y-axis')
}

context.getKey = factPicker.selectedIndex ? (record) => { return { text: record[factPicker.value], style: 'none' }; } : () => { return { text: 'Select fact', style: 'none' }; };

context.cube = pivot.cube(context.json, context.xAxis, context.yAxis);
context.cube = pivot.cube(context.json, context.axes);

const tab = landscape.table(context.cube, context.xAxis, context.yAxis, context.getKey, false);
const tab = landscape.table(context.cube, context.axes, context.getKey, false);
landscape.merge(tab, true, true);

renderTable(tab);
Expand Down
14 changes: 8 additions & 6 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ <h1>Outstanding work</h1>

// globals that we need to keep track of acros functions
let data;
let yAxis;
let xAxis;
let axes;
let cube;
let filtered;

Expand Down Expand Up @@ -226,8 +225,11 @@ <h1>Outstanding work</h1>
//console.time('dimensions');

// create the dimensions to use as the x and y axes; derive from the source data and sort by a pre-defined sequence
xAxis = pivot.deriveDimension(data, xAxisSelector.value, { sort: listSort(sortOrder[xAxisSelector.value]) });
yAxis = pivot.deriveDimension(data, yAxisSelector.value, { sort: listSort(sortOrder[yAxisSelector.value]) });

axes = {
x: pivot.deriveDimension(data, xAxisSelector.value, { sort: listSort(sortOrder[xAxisSelector.value]) }),
y: pivot.deriveDimension(data, yAxisSelector.value, { sort: listSort(sortOrder[yAxisSelector.value]) })
};

/* // create a header dimension
const xAxisHeader = pivot.dimension([xAxisSelector.value], xAxisSelector.value, () => xAxisSelector.value);
Expand All @@ -241,7 +243,7 @@ <h1>Outstanding work</h1>
//console.time('cube');

// create the cube
cube = pivot.cube(data, xAxis, yAxis);
cube = pivot.cube(data, axes);

//console.timeEnd('cube');

Expand Down Expand Up @@ -271,7 +273,7 @@ <h1>Outstanding work</h1>
console.time('split');

// split the cube and axes along the desired axis, creating a table
const table = landscape.table(filtered, xAxis, yAxis, key, splitByX.checked); // NOTE: as the merge function modifies the table, this must be done each time
const table = landscape.table(filtered, axes, key, splitByX.checked); // NOTE: as the merge function modifies the table, this must be done each time

console.timeEnd('split');
console.time('merge');
Expand Down
Loading

0 comments on commit 3e2750d

Please sign in to comment.