Skip to content

Commit 3c03352

Browse files
authored
Merge pull request #881 from finos/allow-missing-columns
Allow missing columns
2 parents 0de060d + 4d8325c commit 3c03352

File tree

42 files changed

+914
-319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+914
-319
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@babel/cli": "^7.2.3",
2626
"@babel/core": "^7.1.0",
2727
"@babel/plugin-proposal-decorators": "^7.1.2",
28+
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
2829
"@babel/plugin-transform-for-of": "^7.0.0",
2930
"@babel/plugin-transform-runtime": "^7.1.0",
3031
"@babel/polyfill": "^7.0.0",

packages/perspective-test/babel.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ module.exports = {
1717
]
1818
],
1919
sourceType: "unambiguous",
20-
plugins: ["lodash", ["@babel/plugin-proposal-decorators", {legacy: true}], "transform-custom-element-classes", "@babel/plugin-proposal-class-properties"]
20+
plugins: [
21+
"lodash",
22+
["@babel/plugin-proposal-decorators", {legacy: true}],
23+
"transform-custom-element-classes",
24+
"@babel/plugin-proposal-optional-chaining",
25+
"@babel/plugin-proposal-class-properties"
26+
]
2127
};

packages/perspective-test/src/js/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const crypto = require("crypto");
1212
const puppeteer = require("puppeteer");
1313
const path = require("path");
1414
const execSync = require("child_process").execSync;
15+
const {track_mouse} = require("./mouse_helper.js");
1516

1617
const readline = require("readline");
1718

@@ -60,6 +61,7 @@ let browser,
6061
async function get_new_page() {
6162
page = await browser.newPage();
6263

64+
page.track_mouse = track_mouse.bind(page);
6365
page.shadow_click = async function(...path) {
6466
await this.evaluate(path => {
6567
let elem = document;
@@ -238,7 +240,7 @@ expect.extend({
238240
}
239241
});
240242

241-
test.capture = function capture(name, body, {timeout = 60000, viewport = null, wait_for_update = true, fail_on_errors = true} = {}) {
243+
test.capture = function capture(name, body, {timeout = 60000, viewport = null, wait_for_update = true, fail_on_errors = true, preserve_hover = false} = {}) {
242244
const _url = page_url;
243245
const _reload_page = page_reload;
244246
const spec = test(
@@ -302,9 +304,12 @@ test.capture = function capture(name, body, {timeout = 60000, viewport = null, w
302304
});
303305
}
304306

307+
// Move the mouse offscreen so prev tests dont get hover effects
308+
await page.mouse.move(10000, 10000);
305309
await body(page);
306-
307-
await page.mouse.move(1000, 1000);
310+
if (!preserve_hover) {
311+
await page.mouse.move(10000, 10000);
312+
}
308313

309314
if (wait_for_update) {
310315
await page.waitForSelector("perspective-viewer:not([updating])");
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/******************************************************************************
2+
*
3+
* Copyright (c) 2017, the Perspective Authors.
4+
*
5+
* This file is part of the Perspective library, distributed under the terms of
6+
* the Apache License 2.0. The full license can be found in the LICENSE file.
7+
*
8+
*/
9+
10+
/**
11+
* This injects a box into the page that moves with the mouse; Useful for
12+
* debugging.
13+
*
14+
* Lifted from https://github.com/puppeteer/puppeteer/issues/4336
15+
*/
16+
module.exports.track_mouse = function track_mouse() {
17+
this.evaluate(() => {
18+
const CSS = `
19+
.mouse-helper {
20+
pointer-events: none;
21+
position: absolute;
22+
top: 0;
23+
left: 0;
24+
width: 20px;
25+
height: 20px;
26+
background: rgba(0,0,0,.4);
27+
border: 1px solid red;
28+
border-radius: 0px;
29+
margin-left: -10px;
30+
margin-top: -10px;
31+
}
32+
.mouse-helper.button-1 {
33+
transition: none;
34+
background: rgba(0,0,0,0.9);
35+
}
36+
.mouse-helper.butto
37+
n-2 {
38+
transition: none;
39+
border-color: rgba(0,0,255,0.9);
40+
}
41+
.mouse-helper.button-3 {
42+
transition: none;
43+
border-radius: 4px;
44+
}
45+
.mouse-helper.button-4 {
46+
transition: none;
47+
border-color: rgba(255,0,0,0.9);
48+
}
49+
.mouse-helper.button-5 {
50+
transition: none;
51+
border-color: rgba(0,255,0,0.9);
52+
}`;
53+
const box = document.createElement("div");
54+
box.classList.add("mouse-helper");
55+
const styleElement = document.createElement("style");
56+
styleElement.innerHTML = CSS;
57+
document.head.appendChild(styleElement);
58+
document.body.appendChild(box);
59+
document.addEventListener(
60+
"mousemove",
61+
event => {
62+
box.style.left = event.pageX + "px";
63+
box.style.top = event.pageY + "px";
64+
updateButtons(event.buttons);
65+
},
66+
true
67+
);
68+
document.addEventListener(
69+
"mousedown",
70+
event => {
71+
updateButtons(event.buttons);
72+
box.classList.add("button-" + event.which);
73+
},
74+
true
75+
);
76+
document.addEventListener(
77+
"mouseup",
78+
event => {
79+
updateButtons(event.buttons);
80+
box.classList.remove("button-" + event.which);
81+
},
82+
true
83+
);
84+
function updateButtons(buttons) {
85+
for (let i = 0; i < 5; i++) box.classList.toggle("button-" + i, buttons & (1 << i));
86+
}
87+
});
88+
};

packages/perspective-viewer-d3fc/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ module.exports = {
1717
]
1818
],
1919
sourceType: "unambiguous",
20-
plugins: ["lodash", ["@babel/plugin-proposal-decorators", {legacy: true}], "transform-custom-element-classes"]
20+
plugins: ["lodash", ["@babel/plugin-proposal-decorators", {legacy: true}], "transform-custom-element-classes", "@babel/plugin-proposal-optional-chaining"]
2121
};

packages/perspective-viewer-d3fc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"build": "npm-run-all --silent build:babel build:webpack:cjs build:webpack:umd",
3434
"test:build": "cpx \"test/html/*\" dist/umd",
3535
"watch": "webpack --color --watch --config src/config/d3fc.watch.config.js",
36-
"test:run": "jest --rootDir=. --config=../perspective-test/jest.config.js --silent --color 2>&1",
36+
"test:run": "jest --rootDir=. --config=../perspective-test/jest.config.js --silent --color --noStackTrace 2>&1",
3737
"test": "npm-run-all test:build test:run",
3838
"clean": "rimraf dist",
3939
"clean:screenshots": "rimraf \"screenshots/**/*.@(failed|diff).png\""

packages/perspective-viewer-d3fc/src/js/charts/sunburst.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ sunburst.plugin = {
7878
max_columns: 50,
7979
initial: {
8080
type: "number",
81-
count: 2,
82-
names: ["Size", "Color"]
81+
count: 1,
82+
names: ["Size", "Color", "Tooltip"]
8383
}
8484
};
8585

packages/perspective-viewer-d3fc/src/js/charts/treemap.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ treemap.plugin = {
6969
max_columns: 50,
7070
initial: {
7171
type: "number",
72-
count: 2
72+
count: 1,
73+
names: ["Size", "Color", "Tooltip"]
7374
}
7475
};
7576
export default treemap;

packages/perspective-viewer-d3fc/src/js/charts/xy-scatter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import nearbyTip from "../tooltip/nearbyTip";
2424
function xyScatter(container, settings) {
2525
const data = pointData(settings, filterDataByGroup(settings));
2626
const symbols = symbolTypeFromGroups(settings);
27-
const useGroupColors = settings.mainValues.length <= 2;
27+
const useGroupColors = settings.realValues.length <= 2 || settings.realValues[2] === null;
2828
let color = null;
2929
let legend = null;
3030

@@ -40,7 +40,7 @@ function xyScatter(container, settings) {
4040
legend = colorRangeLegend().scale(color);
4141
}
4242

43-
const size = settings.mainValues.length > 3 ? seriesLinearRange(settings, data, "size").range([10, 10000]) : null;
43+
const size = settings.realValues[3] ? seriesLinearRange(settings, data, "size").range([10, 10000]) : null;
4444

4545
const series = fc
4646
.seriesCanvasMulti()
@@ -100,7 +100,7 @@ xyScatter.plugin = {
100100
initial: {
101101
type: "number",
102102
count: 2,
103-
names: ["X Axis", "Y Axis", "Color", "Size"]
103+
names: ["X Axis", "Y Axis", "Color", "Size", "Tooltip"]
104104
},
105105
selectMode: "toggle"
106106
};

packages/perspective-viewer-d3fc/src/js/data/pointData.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function seriesToPoints(settings, data) {
2121
mainValues: settings.mainValues.map(v => col[v.name]),
2222
x: col[settings.mainValues[0].name],
2323
y: col[settings.mainValues[1].name],
24-
colorValue: settings.mainValues.length > 2 ? col[settings.mainValues[2].name] : undefined,
25-
size: settings.mainValues.length > 3 ? col[settings.mainValues[3].name] : undefined,
24+
colorValue: settings.realValues[2] ? col[settings.realValues[2]] : undefined,
25+
size: settings.realValues[3] ? col[settings.realValues[3]] : undefined,
2626
key: data.key,
2727
row: col
2828
}));

0 commit comments

Comments
 (0)