diff --git a/package.json b/package.json index b8e4908272..e9849d8ede 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "bench:run": "lerna exec ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} -- npm run bench:run", "bench": "npm-run-all bench:build bench:run", "test:build": "[[ -z \"${PSP_DOCKER}\" ]] && npm run _build_test || npm run _emsdk -- npm run _build_test", - "test:run": "npm run _test_perspective && npm run _test_viewer && npm run _test_hypergrid && npm run _test_highcharts", + "test:run": "npm run --silent _test_perspective && npm run --silent _test_viewer && npm run --silent _test_hypergrid && npm run --silent _test_highcharts", "test": "npm-run-all test:build test:run", "clean": "lerna run clean --stream", - "quiet_test": "npm run _puppeteer -- npm run _quiet_test", + "quiet_test": "npm run --silent _puppeteer -- npm run --silent _quiet_test", "write_tests": "WRITE_TESTS=1 npm run test:run", "postinstall": "lerna bootstrap --hoist", "_build": "lerna run build ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream", @@ -20,9 +20,9 @@ "_emsdk": "docker run --rm -it -v $(pwd):/src -e PACKAGE=${PACKAGE} perspective/emsdk", "_puppeteer": "docker run -it --rm --shm-size=2g -u root -e WRITE_TESTS=${WRITE_TESTS} -v $(pwd):/src -w /src/packages/${PACKAGE} perspective/puppeteer", "_quiet_test": "lerna run test:run ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}}", - "_test_perspective": "PACKAGE=perspective npm run _puppeteer -- npm run test:run", - "_test_viewer": "PACKAGE=perspective-viewer npm run _puppeteer -- npm run test:run", - "_test_hypergrid": "PACKAGE=perspective-viewer-hypergrid npm run _puppeteer -- npm run test:run", - "_test_highcharts": "PACKAGE=perspective-viewer-highcharts npm run _puppeteer -- npm run test:run" + "_test_perspective": "PACKAGE=perspective npm run --silent _puppeteer -- npm run --silent test:run", + "_test_viewer": "PACKAGE=perspective-viewer npm run --silent _puppeteer -- npm run --silent test:run", + "_test_hypergrid": "PACKAGE=perspective-viewer-hypergrid npm run --silent _puppeteer -- npm --silent run test:run", + "_test_highcharts": "PACKAGE=perspective-viewer-highcharts npm run --silent _puppeteer -- npm --silent run test:run" } } diff --git a/packages/perspective-viewer-highcharts/test/results/results.json b/packages/perspective-viewer-highcharts/test/results/results.json index 53caac7198..a63e03761e 100644 --- a/packages/perspective-viewer-highcharts/test/results/results.json +++ b/packages/perspective-viewer-highcharts/test/results/results.json @@ -61,5 +61,10 @@ "treemap.html/filters by a numeric column.": "e79978195df664206e4d8e233a408b6f", "treemap.html/sorts by an alpha column.": "cf3c51e9b18fddade098bd7203ed4832", "treemap.html/displays visible columns.": "7f8e4756e554bc34920ea32eaf0373ae", - "treemap.html/tooltip shows on hover.": "d82160988637350390ed0f1c13794762" + "treemap.html/tooltip shows on hover.": "d82160988637350390ed0f1c13794762", + "scatter.html/pivots by a column.": "a1bf47633d4f11fa9e026df63a6a2983", + "heatmap.html/pivots by a column.": "a30c031a166ce10b925fade0fa727568", + "line.html/pivots by a column.": "a9cdbcf9dc241c5a11077c325765eac4", + "bar.html/pivots by a column.": "e38874f04098eabf0feb0dad278d7a05", + "treemap.html/pivots by a column.": "716d4b3985568360c5f61f9c8f20ac69" } \ No newline at end of file diff --git a/packages/perspective-viewer-hypergrid/test/results/results.json b/packages/perspective-viewer-hypergrid/test/results/results.json index a2f7647f5f..e2d90ed7a7 100644 --- a/packages/perspective-viewer-hypergrid/test/results/results.json +++ b/packages/perspective-viewer-hypergrid/test/results/results.json @@ -10,5 +10,6 @@ "superstore.html/resets viewable area when the logical size expands.": "b7bf4b0d438ccd2141f56d5582d7d1af", "superstore.html/resets viewable area when the physical size expands.": "5c9f7fcce4e9bb1f144409afbc43b0fa", "superstore.html/sorts by a hidden column.": "9b7f9c4f32d5c55d30294391cba272a6", - "superstore.html/filters by a numeric column.": "52f89aceca9f801cbcb7932535a14370" + "superstore.html/filters by a numeric column.": "52f89aceca9f801cbcb7932535a14370", + "superstore.html/pivots by a column.": "3179b8b88a1915425ec41406cd7516cd" } \ No newline at end of file diff --git a/packages/perspective-viewer/test/js/simple_tests.js b/packages/perspective-viewer/test/js/simple_tests.js index 8e92e06238..4706b93e88 100644 --- a/packages/perspective-viewer/test/js/simple_tests.js +++ b/packages/perspective-viewer/test/js/simple_tests.js @@ -24,6 +24,12 @@ exports.default = function() { await page.evaluate(element => element.setAttribute('row-pivots', '["Category","Sub-Category"]'), viewer); }); + test.capture("pivots by a column.", async page => { + await page.click('#config_button'); + const viewer = await page.$('perspective-viewer'); + await page.evaluate(element => element.setAttribute('column-pivots', '["Category"]'), viewer); + }); + test.capture("pivots by a row and a column.", async page => { await page.click('#config_button'); const viewer = await page.$('perspective-viewer'); diff --git a/packages/perspective-viewer/test/results/results.json b/packages/perspective-viewer/test/results/results.json index c063186648..722e2a26ef 100644 --- a/packages/perspective-viewer/test/results/results.json +++ b/packages/perspective-viewer/test/results/results.json @@ -10,5 +10,6 @@ "superstore.html/sorts by a hidden column.": "ea40ec5853b636e0d218815b7ffd5ba8", "superstore.html/filters by a numeric column.": "d8d1fecdb6ae6cf8b07f5d38b03944c0", "superstore.html/shows horizontal columns on small viewports.": "64f400a8d9ec3c345bb61d097c3c1c55", - "blank.html/Handles reloading with a schema.": "12aece0a0c593b9fe8fd7966abd75b32" + "blank.html/Handles reloading with a schema.": "12aece0a0c593b9fe8fd7966abd75b32", + "superstore.html/pivots by a column.": "743cae89803c62ef46eeff5c89b7dae3" } \ No newline at end of file diff --git a/packages/perspective/src/js/perspective.js b/packages/perspective/src/js/perspective.js index 859142db60..ea4ec7ba2f 100644 --- a/packages/perspective/src/js/perspective.js +++ b/packages/perspective/src/js/perspective.js @@ -581,7 +581,7 @@ const to_format = async function (options, formatter) { formatter.addRow(data, row); } if (this.config.row_pivot[0] === 'psp_okey') { - data = data.slice(this.config.column_pivot.length); + data = formatter.slice(data, this.config.column_pivot.length); } return formatter.formatData(data, options.config) diff --git a/packages/perspective/src/js/view_formatters.js b/packages/perspective/src/js/view_formatters.js index a5104ae623..caadf8c570 100644 --- a/packages/perspective/src/js/view_formatters.js +++ b/packages/perspective/src/js/view_formatters.js @@ -16,7 +16,8 @@ const jsonFormatter = { setColumnValue: (data, row, colName, value) => row[colName] = value, addColumnValue: (data, row, colName, value) => row[colName].unshift(value), addRow: (data, row) => data.push(row), - formatData: data => data + formatData: data => data, + slice: (data, start, length) => data.slice(start, length) }; const csvFormatter = Object.assign({}, jsonFormatter, { @@ -39,7 +40,13 @@ const jsonTableFormatter = { data[colName].push([]); }, addRow: (data, row) => {}, - formatData: data => data + formatData: data => data, + slice: (data, start, length) => { + for (let x in data) { + data[x].splice(start, length); + } + return data; + } } export default {