Skip to content

Commit

Permalink
Merge pull request #191 from jpmorganchase/column-pivot-fix
Browse files Browse the repository at this point in the history
Fixed Hypergrid regression in column-only pivot
  • Loading branch information
texodus authored Aug 14, 2018
2 parents 7c92d4a + 2a933a6 commit e36f34d
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 18 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"rimraf": "^2.6.2"
},
"scripts": {
"build": "[[ -z \"${PSP_DOCKER}\" ]] && npm run _build || npm run _emsdk -- npm run _build",
"build": "[[ -z \"${PSP_DOCKER}\" ]] && npm run --silent _build || npm run --silent _emsdk -- npm run --silent _build",
"bench:build": "lerna run bench:build ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream",
"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:build": "[[ -z \"${PSP_DOCKER}\" ]] && npm run --silent _build_test || npm run --silent _emsdk -- npm run --silent _build_test",
"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",
"_build_test": "lerna run test:build ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}} --stream",
"_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"
}
}
2 changes: 1 addition & 1 deletion packages/perspective-viewer-highcharts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "npm run highcharts",
"test:build": "cp test/html/* build && webpack --color --config test/config/highcharts.config.js",
"watch_test": "cp test/html* build && webpack --color --config --watch test/config/highcharts.config.js",
"test:run": "jest --silent 2>&1",
"test:run": "jest --silent --color 2>&1",
"test": "npm-run-all test:build test:run",
"clean": "find build -mindepth 1 -delete",
"clean:screenshots": "find screenshots/ -name *.diff.png -o -name *.failed.png -mindepth 1 -delete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/perspective-viewer-hypergrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"hypergrid": "webpack --color --config src/config/hypergrid.plugin.config.js",
"build": "npm run hypergrid",
"test:build": "cp test/html/* build && webpack --color --config test/config/hypergrid.config.js",
"test:run": "jest --silent 2>&1",
"test:run": "jest --silent --color 2>&1",
"test": "npm-run-all test:build test:run",
"clean": "find build -mindepth 1 -delete",
"clean:screenshots": "find screenshots/ -name *.diff.png -o -name *.failed.png -mindepth 1 -delete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/perspective-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"view": "webpack --color --config src/config/view.config.js",
"build": "npm run view && npm run themes",
"test:build": "cp test/html/* build && cp test/csv/* build && cp test/css/* build && webpack --color --config test/config/view.config.js",
"test:run": "jest --silent 2>&1",
"test:run": "jest --silent --color 2>&1",
"test": "npm-run-all test:build test:run",
"clean": "find build -mindepth 1 -delete",
"clean:screenshots": "find screenshots/ -name *.diff.png -o -name *.failed.png -mindepth 1 -delete",
Expand Down
6 changes: 6 additions & 0 deletions packages/perspective-viewer/test/js/simple_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion packages/perspective-viewer/test/results/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test:build:webpack:browser": "webpack --color --config test/config/test_browser.config.js",
"test:build:webpack:node": "webpack --color --config test/config/test_node.config.js",
"docs": "documentation build src/js/perspective.js -f md --shallow > README.md",
"test:run": "jest --runInBand 2>&1",
"test:run": "jest --runInBand --color 2>&1",
"test": "npm-run-all test:build test:run",
"clean": "find build -mindepth 1 -delete && find obj -mindepth 1 -delete"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions packages/perspective/src/js/view_formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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 {
Expand Down

0 comments on commit e36f34d

Please sign in to comment.