chore: import upstream snapshot with attribution
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
||||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
||||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
||||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
||||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
||||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
||||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
||||
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
||||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
||||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
export const LAYOUTS: Record<string, any> = {
|
||||
sparkgrid: {
|
||||
plugin: "Datagrid",
|
||||
plugin_config: {
|
||||
columns: {},
|
||||
scroll_lock: true,
|
||||
},
|
||||
columns_config: {
|
||||
"chg (-)": {
|
||||
number_fg_mode: "bar",
|
||||
fg_gradient: 14.34,
|
||||
},
|
||||
chg: {
|
||||
number_bg_mode: "gradient",
|
||||
bg_gradient: 29.17,
|
||||
},
|
||||
"chg (+)": {
|
||||
number_fg_mode: "bar",
|
||||
fg_gradient: 17.4,
|
||||
},
|
||||
},
|
||||
group_rollup_mode: "rollup",
|
||||
settings: true,
|
||||
title: "Market Monitor",
|
||||
group_by: ["name"],
|
||||
split_by: ["client"],
|
||||
columns: ["chg (-)", "chg", "chg (+)"],
|
||||
filter: [],
|
||||
sort: [["chg", "desc"]],
|
||||
expressions: {
|
||||
"chg (+)": 'if("chg">0){"chg"}else{0}',
|
||||
"chg (-)": 'if("chg"<0){"chg"}else{0}',
|
||||
},
|
||||
aggregates: {
|
||||
chg: "avg",
|
||||
"chg (+)": "avg",
|
||||
"chg (-)": "avg",
|
||||
},
|
||||
},
|
||||
datagrid: {
|
||||
plugin: "datagrid",
|
||||
title: "Blotter",
|
||||
columns: ["ask", "bid", "chg"],
|
||||
group_rollup_mode: "rollup",
|
||||
sort: [
|
||||
["name", "desc"],
|
||||
["lastUpdate", "desc"],
|
||||
],
|
||||
aggregates: { name: "last", lastUpdate: "last" },
|
||||
group_by: ["name", "lastUpdate"],
|
||||
split_by: ["client"],
|
||||
plugin_config: {},
|
||||
},
|
||||
"x bar": {
|
||||
title: "Px (Δ)",
|
||||
group_rollup_mode: "flat",
|
||||
columns: ["chg"],
|
||||
plugin: "X Bar",
|
||||
sort: [["chg", "asc"]],
|
||||
group_by: ["name"],
|
||||
split_by: ["client"],
|
||||
},
|
||||
"y line": {
|
||||
title: "Time Series (Px)",
|
||||
group_rollup_mode: "flat",
|
||||
plugin: "Y Line",
|
||||
group_by: ["lastUpdate"],
|
||||
sort: [["lastUpdate", "desc"]],
|
||||
split_by: ["client"],
|
||||
columns: ["bid"],
|
||||
aggregates: { bid: "avg", chg: "avg", name: "last" },
|
||||
},
|
||||
"xy scatter": {
|
||||
title: "Spread Scatter",
|
||||
group_rollup_mode: "flat",
|
||||
plugin: "X/Y Scatter",
|
||||
group_by: ["name"],
|
||||
split_by: [],
|
||||
columns: ["bid", "ask", "chg", "vol", null, "name"],
|
||||
aggregates: { bid: "avg", ask: "avg", vol: "avg", name: "dominant" },
|
||||
sort: [],
|
||||
},
|
||||
treemap: {
|
||||
plugin: "Treemap",
|
||||
group_rollup_mode: "flat",
|
||||
title: "Volume Map",
|
||||
group_by: ["name", "client"],
|
||||
split_by: [],
|
||||
columns: ["vol", "chg"],
|
||||
aggregates: { bid: "sum", chg: "sum", name: "last" },
|
||||
sort: [
|
||||
["name", "desc"],
|
||||
["chg", "desc"],
|
||||
],
|
||||
},
|
||||
heatmap: {
|
||||
group_rollup_mode: "flat",
|
||||
title: "Spread Heatmap",
|
||||
columns: ["name"],
|
||||
plugin: "Heatmap",
|
||||
expressions: {
|
||||
'bucket("bid",2)': 'bucket("bid",2)',
|
||||
'bucket("ask",2)': `bucket("ask",2)`,
|
||||
},
|
||||
group_by: [`bucket("bid",2)`],
|
||||
split_by: [`bucket("ask",2)`],
|
||||
sort: [],
|
||||
aggregates: {},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
||||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
||||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
||||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
||||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
||||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
||||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
||||
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
||||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
||||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
const SECURITIES = [
|
||||
"AAPL.N",
|
||||
"MSFT.N",
|
||||
"AMZN.N",
|
||||
"GOOGL.N",
|
||||
"FB.N",
|
||||
"TSLA.N",
|
||||
"BABA.N",
|
||||
"TSM.N",
|
||||
"V.N",
|
||||
"NVDA.N",
|
||||
"JPM.N",
|
||||
"JNJ.N",
|
||||
"WMT.N",
|
||||
"UNH.N",
|
||||
"MA.N",
|
||||
"BAC.N",
|
||||
"DIS.N",
|
||||
"ASML.N",
|
||||
"ADBE.N",
|
||||
"CMCSA.N",
|
||||
"NKE.N",
|
||||
"XOM.N",
|
||||
"TM.N",
|
||||
"KO.N",
|
||||
"ORCL.N",
|
||||
"NFLX.N",
|
||||
];
|
||||
|
||||
const CLIENTS = [
|
||||
"Homer",
|
||||
"Marge",
|
||||
"Bart",
|
||||
"Lisa",
|
||||
"Maggie",
|
||||
"Barney",
|
||||
"Ned",
|
||||
"Moe",
|
||||
];
|
||||
|
||||
let id = 0;
|
||||
|
||||
function randn_bm(): number {
|
||||
let u = 0,
|
||||
v = 0;
|
||||
while (u === 0) u = Math.random();
|
||||
while (v === 0) v = Math.random();
|
||||
return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
|
||||
}
|
||||
|
||||
export function random_row() {
|
||||
id = id % 1000;
|
||||
return {
|
||||
name: SECURITIES[Math.floor(Math.random() * SECURITIES.length)],
|
||||
client: CLIENTS[Math.floor(Math.random() * CLIENTS.length)],
|
||||
lastUpdate: new Date(),
|
||||
chg: randn_bm() * 10,
|
||||
bid: randn_bm() * 5 + 95,
|
||||
ask: randn_bm() * 5 + 105,
|
||||
vol: randn_bm() * 5 + 105,
|
||||
id: id++,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
||||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
||||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
||||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
||||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
||||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
||||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
||||
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
||||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
||||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
import { worker } from "./worker.js";
|
||||
// @ts-ignore
|
||||
import SUPERSTORE_URL from "superstore-arrow/superstore.lz4.arrow";
|
||||
|
||||
export const WORKER = worker();
|
||||
|
||||
export const SUPERSTORE_TABLE = (async function () {
|
||||
const req = await fetch(SUPERSTORE_URL);
|
||||
const arrow = await req.arrayBuffer();
|
||||
return await WORKER.then((w) =>
|
||||
w.table(arrow.slice(), { name: "superstore" }),
|
||||
);
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
||||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
||||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
||||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
||||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
||||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
||||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
||||
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
||||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
||||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
const WORKER = (async () => {
|
||||
const perspective = await import("@perspective-dev/client");
|
||||
const perspective_viewer = await import("@perspective-dev/viewer");
|
||||
const server_wasm = import(
|
||||
"@perspective-dev/server/dist/wasm/perspective-server.wasm"
|
||||
);
|
||||
|
||||
const client_wasm = import(
|
||||
"@perspective-dev/viewer/dist/wasm/perspective-viewer.wasm"
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
perspective.init_server(server_wasm.then((x: any) => x.default)),
|
||||
perspective_viewer.init_client(client_wasm.then((x: any) => x.default)),
|
||||
]);
|
||||
|
||||
return await perspective.worker();
|
||||
})();
|
||||
|
||||
export function worker() {
|
||||
return WORKER;
|
||||
}
|
||||
Reference in New Issue
Block a user