Skip to content

Commit f67b01f

Browse files
authored
Merge pull request #550 from jpmorganchase/misc-cleanup
Misc cleanup
2 parents 17a39de + ed4439b commit f67b01f

File tree

9 files changed

+45
-61
lines changed

9 files changed

+45
-61
lines changed

packages/perspective-cli/src/html/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
}
4444
</style>
4545
</head>
46+
4647
<body>
47-
<perspective-viewer id="view1"></perspective-viewer>
48+
<perspective-viewer id="view1"></perspective-viewer>
4849
<script>
4950
window.addEventListener('WebComponentsReady', function() {
5051
var elem = document.getElementById('view1');
@@ -53,4 +54,5 @@
5354
});
5455
</script>
5556
</body>
57+
5658
</html>

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*/
99

10-
const {WebSocketHost, table} = require("@jpmorganchase/perspective/build/perspective.node.js");
10+
const {WebSocketHost, table} = require("@jpmorganchase/perspective");
1111
const {read_stdin, open_browser} = require("./utils.js");
1212
const fs = require("fs");
1313
const path = require("path");
@@ -66,8 +66,11 @@ async function convert(filename, options) {
6666
* @param {*} options
6767
*/
6868
async function host(filename, options) {
69-
const files = path.join(__dirname, "html");
70-
const server = new WebSocketHost({assets: [files], port: options.port});
69+
let files = [path.join(__dirname, "html")];
70+
if (options.assets) {
71+
files = [options.assets, ...files];
72+
}
73+
const server = new WebSocketHost({assets: files, port: options.port});
7174
let file;
7275
if (filename) {
7376
file = fs.readFileSync(filename).toString();
@@ -96,6 +99,7 @@ program
9699
.command("host [filename]")
97100
.description("Host a file on a local Websocket/HTTP server using a server-side Perspective. Reads from STDIN if no filename is provided")
98101
.option("-p, --port <port>", "Which port to bind to.", x => parseInt(x), 8080)
102+
.option("-a, --assets <path>", "Host from a working directory")
99103
.option("-o, --open", "Open a browser automagically.")
100104
.action(host);
101105

packages/perspective-jupyterlab/src/less/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ div.PSPContainer perspective-viewer,
1111
div.PSPContainer-dark perspective-viewer {
1212
display: block;
1313
height: 95%;
14-
}
14+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<template id="perspective-d3fc-chart">
2-
<div id="container" class="chart">
3-
</div>
2+
<div id="container" class="chart">
3+
</div>
44
</template>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template id="perspective-d3fc">
22
<div id="container">
3-
3+
44
</div>
55
</template>

packages/perspective-viewer/src/js/viewer.js

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {ActionElement} from "./viewer/action_element.js";
2828
polyfill({});
2929

3030
/**
31-
* Module for `<perspective-viewer` custom element. There are no exports from
31+
* Module for `<perspective-viewer>` custom element. There are no exports from
3232
* this module, however importing it has a side effect: the
3333
* {@link module:perspective_viewer~PerspectiveViewer} class is registered as a
3434
* custom element, after which it can be used as a standard DOM element. The
@@ -64,7 +64,6 @@ class PerspectiveViewer extends ActionElement {
6464
constructor() {
6565
super();
6666
this._register_debounce_instance();
67-
this._slaves = [];
6867
this._show_config = true;
6968
this._show_warnings = true;
7069
this._resize_handler = _.debounce(this.notifyResize, 250).bind(this);
@@ -307,29 +306,6 @@ class PerspectiveViewer extends ActionElement {
307306
this._debounce_update();
308307
}
309308

310-
/**
311-
* When set, hide the data visualization and display the message. Setting
312-
* `message` does not clear the internal `perspective.table`, but it does
313-
* render it hidden until the message is removed.
314-
*
315-
* @param {string} msg The message. This can be HTML - it is not sanitized.
316-
* @example
317-
* let elem = document.getElementById('my_viewer');
318-
* elem.setAttribute('message', '<h1>Loading</h1>');
319-
*/
320-
message(msg) {
321-
if (this.getAttribute("message") !== msg) {
322-
this.setAttribute("message", msg);
323-
return;
324-
}
325-
if (!this._inner_drop_target) return;
326-
this.shadowRoot.querySelector("#app").classList.remove("hide_message");
327-
this._inner_drop_target.innerHTML = msg;
328-
for (let slave of this._slaves) {
329-
slave.setAttribute("message", msg);
330-
}
331-
}
332-
333309
/**
334310
* This element's `perspective` worker instance. This property is not
335311
* reflected as an HTML attribute, and is readonly; it can be effectively
@@ -346,6 +322,15 @@ class PerspectiveViewer extends ActionElement {
346322
return this._get_worker();
347323
}
348324

325+
/**
326+
* This element's `perspective.table` instance.
327+
*
328+
* @readonly
329+
*/
330+
get table() {
331+
return this._table;
332+
}
333+
349334
/**
350335
* This element's `perspective.table.view` instance. The instance itself
351336
* will change after every `PerspectiveViewer#perspective-config-update` event.
@@ -390,12 +375,7 @@ class PerspectiveViewer extends ActionElement {
390375
table = this.worker.table(data, options);
391376
table._owner_viewer = this;
392377
}
393-
let _promises = [this._load_table(table)];
394-
for (let slave of this._slaves) {
395-
_promises.push(this._load_table.call(slave, table));
396-
}
397-
this._slaves = [];
398-
return Promise.all(_promises);
378+
return this._load_table(table);
399379
}
400380

401381
/**
@@ -445,11 +425,8 @@ class PerspectiveViewer extends ActionElement {
445425
this._inner_drop_target.innerHTML = widget._inner_drop_target.innerHTML;
446426
}
447427

448-
if (widget._table) {
449-
this._load_table(widget._table);
450-
} else {
451-
widget._slaves.push(this);
452-
}
428+
this._load_table(widget.table);
429+
this.restore(widget.save());
453430
}
454431

455432
/**

packages/perspective-viewer/src/js/viewer/perspective_element.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export class PerspectiveElement extends StateElement {
303303
task.cancel();
304304
if (this._render_count === 0) {
305305
this.removeAttribute("updating");
306+
this.dispatchEvent(new Event("perspective-update-complete"));
306307
}
307308
}
308309
}

packages/perspective-viewer/src/less/viewer.less

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
--hypergrid-row-hover--color: #666;
7676
--hypergrid-cell-hover--background: #eeeeee;
7777
--hypergrid-cell-hover--color: #666;
78-
78+
7979
--d3fc-series: rgba(31, 119, 180, 0.5);
8080
--d3fc-series-1: #0366d6;
8181
--d3fc-series-2: #ff7f0e;
@@ -88,25 +88,25 @@
8888
--d3fc-series-9: #bcbd22;
8989
--d3fc-series-10: #17becf;
9090
--d3fc-gradient-full: linear-gradient(
91-
#4d342f 0%,
92-
#e4521b 22.5%,
93-
#feeb65 42.5%,
94-
#f0f0f0 50%,
95-
#dcedc8 57.5%,
96-
#42b3d5 67.5%,
97-
#1a237e 100%
98-
);
91+
#4d342f 0%,
92+
#e4521b 22.5%,
93+
#feeb65 42.5%,
94+
#f0f0f0 50%,
95+
#dcedc8 57.5%,
96+
#42b3d5 67.5%,
97+
#1a237e 100%
98+
);
9999
--d3fc-gradient-positive: linear-gradient(
100-
#dcedc8 0%,
101-
#42b3d5 35%,
102-
#1a237e 100%
100+
#dcedc8 0%,
101+
#42b3d5 35%,
102+
#1a237e 100%
103103
);
104104
--d3fc-gradient-negative: linear-gradient(
105-
#feeb65 100%,
106-
#e4521b 70%,
107-
#4d342f 0%
105+
#feeb65 100%,
106+
#e4521b 70%,
107+
#4d342f 0%
108108
);
109-
109+
110110
#pivot_chart {
111111
position: absolute;
112112
width: 100%;

packages/perspective-viewer/src/themes/material.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ perspective-viewer {
4242

4343
--sort-order-asc--before: "arrow_upward";
4444
--sort-order-desc--before: "arrow_downward";
45-
--sort-order-none--before: "-";
45+
--sort-order-none--before: "remove";
4646
--sort-order-col-asc--before: "arrow_back";
4747
--sort-order-col-desc--before: "arrow_forward";
4848
--sort_order-padding: 0 0 0 0px;

0 commit comments

Comments
 (0)