forked from finos/perspective
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (46 loc) · 1.78 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/******************************************************************************
*
* Copyright (c) 2018, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import perspective from "@finos/perspective";
import "@finos/perspective-workspace";
import "@finos/perspective-viewer-hypergrid";
import "@finos/perspective-viewer-d3fc";
import "./index.less";
const datasource = async () => {
const req = fetch("./superstore.arrow");
const resp = await req;
const buffer = await resp.arrayBuffer();
const worker = perspective.shared_worker();
return worker.table(buffer);
};
document.body.innerHTML = `
<perspective-workspace id="workspace">
<perspective-viewer slot="One" name="Test Widget One" table="superstore"></perspective-viewer>
<perspective-viewer slot="Two" name="Test Widget Two" table="superstore"></perspective-viewer>
<perspective-viewer slot="Three" name="Test Widget Three" table="superstore"></perspective-viewer>
</perspective-workspace>
`;
window.addEventListener("load", () => {
window.workspace.tables.set("superstore", datasource());
window.workspace.restore({
master: {
widgets: ["Four", "Three"]
},
detail: {
main: {
currentIndex: 0,
type: "tab-area",
widgets: ["One", "Two"]
}
},
viewers: {
Three: {table: "superstore", name: "Test Widget III (modified)", "row-pivots": ["State"], columns: ["Sales", "Profit"]},
Four: {table: "superstore", name: "Test Widget IV (modified)", "row-pivots": ["Category", "Sub-Category"], columns: ["Sales", "Profit"]}
}
});
});