@eox/chart 2.0.0-alpha12 → 2.0.0-alpha14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/eox-chart.js +15340 -0
- package/dist/eox-chart.umd.cjs +121 -0
- package/package.json +7 -30
- package/test/general.cy.ts +36 -0
- package/{dist/test.html → test/general.html} +5 -9
- package/test/sh.json +417 -0
- package/test/shDisplay.cy.ts +22 -0
- package/test/signalsEndpoint.cy.ts +171 -0
- package/dist/assets/main-6438d57a.js +0 -25
- package/dist/index.html +0 -83
- package/dist/interface.mjs +0 -108
- package/dist/interface.umd.js +0 -1
- package/scripts/watch.mjs +0 -34
- package/src/Chart.ce.vue +0 -206
- package/src/OLD_main.ts +0 -111
- package/src/chartControls.ts +0 -201
- package/src/interface.ts +0 -93
- package/src/main.ts +0 -111
- package/src/signalsDataManager.ts +0 -601
- package/src/vite-env.d.ts +0 -1
- package/typings/global.d.ts +0 -9
package/dist/index.html
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<title>EOxElements Chart</title>
|
|
6
|
-
<style>
|
|
7
|
-
* {
|
|
8
|
-
font-family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif";
|
|
9
|
-
font-size: 0.95em;
|
|
10
|
-
}
|
|
11
|
-
label {
|
|
12
|
-
margin-top: 2.5px;
|
|
13
|
-
}
|
|
14
|
-
html,
|
|
15
|
-
body {
|
|
16
|
-
margin: 0;
|
|
17
|
-
padding: 0;
|
|
18
|
-
}
|
|
19
|
-
html,
|
|
20
|
-
body,
|
|
21
|
-
.chart {
|
|
22
|
-
width: 100%;
|
|
23
|
-
height: 100%;
|
|
24
|
-
}
|
|
25
|
-
.hidden {
|
|
26
|
-
visibility: hidden;
|
|
27
|
-
}
|
|
28
|
-
.loader {
|
|
29
|
-
position: absolute;
|
|
30
|
-
top: 5px;
|
|
31
|
-
right: 30px;
|
|
32
|
-
width: 24px;
|
|
33
|
-
height: 24px;
|
|
34
|
-
border-radius: 50%;
|
|
35
|
-
display: inline-block;
|
|
36
|
-
border-top: 4px solid #000;
|
|
37
|
-
border-right: 4px solid transparent;
|
|
38
|
-
box-sizing: border-box;
|
|
39
|
-
animation: rotation 1s linear infinite;
|
|
40
|
-
}
|
|
41
|
-
.loader::after {
|
|
42
|
-
content: "";
|
|
43
|
-
box-sizing: border-box;
|
|
44
|
-
position: absolute;
|
|
45
|
-
left: 0;
|
|
46
|
-
top: 0;
|
|
47
|
-
width: 24px;
|
|
48
|
-
height: 24px;
|
|
49
|
-
border-radius: 50%;
|
|
50
|
-
border-left: 4px solid #004170;
|
|
51
|
-
border-bottom: 4px solid transparent;
|
|
52
|
-
animation: rotation 0.5s linear infinite reverse;
|
|
53
|
-
}
|
|
54
|
-
@keyframes rotation {
|
|
55
|
-
0% {
|
|
56
|
-
transform: rotate(0deg);
|
|
57
|
-
}
|
|
58
|
-
100% {
|
|
59
|
-
transform: rotate(360deg);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
#controls {
|
|
63
|
-
position: absolute;
|
|
64
|
-
width: 100%;
|
|
65
|
-
display: flex;
|
|
66
|
-
gap: 5px;
|
|
67
|
-
flex-direction: row;
|
|
68
|
-
}
|
|
69
|
-
.parsingError {
|
|
70
|
-
background-color: #ff6d6d;
|
|
71
|
-
}
|
|
72
|
-
#chart {
|
|
73
|
-
padding-top: 30px;
|
|
74
|
-
}
|
|
75
|
-
</style>
|
|
76
|
-
<script type="module" crossorigin src="./assets/main-6438d57a.js"></script>
|
|
77
|
-
</head>
|
|
78
|
-
<body>
|
|
79
|
-
<div id="controls" class="controls" data-cy="controls"></div>
|
|
80
|
-
<canvas id="chart" class="chart" data-cy="chart"></canvas>
|
|
81
|
-
|
|
82
|
-
</body>
|
|
83
|
-
</html>
|
package/dist/interface.mjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var f = Object.defineProperty;
|
|
2
|
-
var x = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
-
var h = (s, t, e) => (x(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
-
const b = "@eox/chart", w = "2.0.0-alpha12", v = {
|
|
5
|
-
"chart.js": "^4.2.1",
|
|
6
|
-
"chartjs-adapter-luxon": "^1.3.1",
|
|
7
|
-
"chartjs-chart-error-bars": "^4.1.2"
|
|
8
|
-
}, D = {
|
|
9
|
-
"@eox/eslint-config": "^1.0.0",
|
|
10
|
-
"@types/luxon": "^3.2.0",
|
|
11
|
-
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
12
|
-
"@typescript-eslint/parser": "^5.50.0",
|
|
13
|
-
cypress: "^12.6.0",
|
|
14
|
-
"cypress-vite": "^1.3.0",
|
|
15
|
-
"eslint-plugin-cypress": "^2.12.1",
|
|
16
|
-
"eslint-plugin-typescript": "^0.14.0",
|
|
17
|
-
install: "^0.13.0",
|
|
18
|
-
luxon: "^3.3.0",
|
|
19
|
-
npm: "^9.6.3",
|
|
20
|
-
"p-retry": "^5.1.2",
|
|
21
|
-
"pre-commit": "^1.2.2",
|
|
22
|
-
"start-server-and-test": "^1.15.2",
|
|
23
|
-
typescript: "^4.9.3",
|
|
24
|
-
vite: "^4.0.0"
|
|
25
|
-
}, M = {
|
|
26
|
-
npm: ">=8.0.0",
|
|
27
|
-
node: ">=18.0.0"
|
|
28
|
-
}, j = [
|
|
29
|
-
"dist",
|
|
30
|
-
"scripts",
|
|
31
|
-
"src",
|
|
32
|
-
"typings"
|
|
33
|
-
], S = "./dist/interface.mjs", C = {
|
|
34
|
-
start: "vite",
|
|
35
|
-
build: "tsc && vite build --config vite.config.interface.ts && vite build --config vite.config.map.ts",
|
|
36
|
-
watch: "node scripts/watch.mjs",
|
|
37
|
-
preview: "vite preview",
|
|
38
|
-
format: "prettier --write .",
|
|
39
|
-
lint: "eslint --ext .js,.ts .",
|
|
40
|
-
"lint:fix": "eslint --ext .js,.ts . --fix",
|
|
41
|
-
cypress: "start-server-and-test start 5173 'cypress open'",
|
|
42
|
-
test: "start-server-and-test start 5173 'cypress run'"
|
|
43
|
-
}, E = {
|
|
44
|
-
name: b,
|
|
45
|
-
version: w,
|
|
46
|
-
dependencies: v,
|
|
47
|
-
devDependencies: D,
|
|
48
|
-
engines: M,
|
|
49
|
-
files: j,
|
|
50
|
-
main: S,
|
|
51
|
-
scripts: C,
|
|
52
|
-
"pre-commit": [
|
|
53
|
-
"format",
|
|
54
|
-
"lint:fix"
|
|
55
|
-
]
|
|
56
|
-
}, u = new MessageChannel(), n = u.port1;
|
|
57
|
-
class k {
|
|
58
|
-
constructor(t) {
|
|
59
|
-
h(this, "iframe");
|
|
60
|
-
this.iframe = t;
|
|
61
|
-
}
|
|
62
|
-
setData(t) {
|
|
63
|
-
n.postMessage({ type: "setData", body: { data: t } });
|
|
64
|
-
}
|
|
65
|
-
setSignalsData(t) {
|
|
66
|
-
n.postMessage({ type: "setSignalsData", body: { data: t } });
|
|
67
|
-
}
|
|
68
|
-
setSignalsEndpoint(t) {
|
|
69
|
-
n.postMessage({ type: "setSignalsEndpoint", body: { options: t } });
|
|
70
|
-
}
|
|
71
|
-
setSignalsGeometry(t) {
|
|
72
|
-
n.postMessage({ type: "setSignalsGeometry", body: { geometry: t } });
|
|
73
|
-
}
|
|
74
|
-
setOptions(t) {
|
|
75
|
-
n.postMessage({ type: "setOptions", body: { options: t } });
|
|
76
|
-
}
|
|
77
|
-
getFoo() {
|
|
78
|
-
return new Promise((t) => {
|
|
79
|
-
const e = Date.now();
|
|
80
|
-
n.onmessage = (o) => {
|
|
81
|
-
o.data.ts === e && t(o.data.body);
|
|
82
|
-
}, n.postMessage({ ts: e, type: "getFoo", body: "hello world" });
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const $ = (s) => s ? new Promise((t) => {
|
|
87
|
-
var a, c, p, l;
|
|
88
|
-
const e = document.createElement("iframe");
|
|
89
|
-
if (e.style.cssText = "width: 100%; height: 100%; display: block; margin: 0; border: none;", e.setAttribute(
|
|
90
|
-
"src",
|
|
91
|
-
(c = (a = import.meta) == null ? void 0 : a.url) != null && c.includes("localhost") ? "http://localhost:5173/index.html" : "about:blank"
|
|
92
|
-
), e.setAttribute("id", "EOxChart"), s == null || s.appendChild(e), !((l = (p = import.meta) == null ? void 0 : p.url) != null && l.includes("localhost"))) {
|
|
93
|
-
const r = `https://www.unpkg.com/@eox/chart@${E.version}/dist`;
|
|
94
|
-
fetch(`${r}/index.html`).then((i) => i.text()).then((i) => {
|
|
95
|
-
var d, m, g;
|
|
96
|
-
const y = i.replace("./assets/", `${r}/assets/`);
|
|
97
|
-
(d = e.contentDocument) == null || d.open(), (m = e.contentDocument) == null || m.write(y), (g = e.contentDocument) == null || g.close();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
let o = !1;
|
|
101
|
-
e.onload = () => {
|
|
102
|
-
var r;
|
|
103
|
-
o || ((r = e.contentWindow) == null || r.postMessage("init", "*", [u.port2]), o = !0, t(new k(e)));
|
|
104
|
-
};
|
|
105
|
-
}) : (console.error("no div selected"), null);
|
|
106
|
-
export {
|
|
107
|
-
$ as createChart
|
|
108
|
-
};
|
package/dist/interface.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(n,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.Interface={}))})(this,function(n){"use strict";var v=Object.defineProperty;var S=(n,s,o)=>s in n?v(n,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[s]=o;var y=(n,s,o)=>(S(n,typeof s!="symbol"?s+"":s,o),o);const g={name:"@eox/chart",version:"2.0.0-alpha12",dependencies:{"chart.js":"^4.2.1","chartjs-adapter-luxon":"^1.3.1","chartjs-chart-error-bars":"^4.1.2"},devDependencies:{"@eox/eslint-config":"^1.0.0","@types/luxon":"^3.2.0","@typescript-eslint/eslint-plugin":"^5.50.0","@typescript-eslint/parser":"^5.50.0",cypress:"^12.6.0","cypress-vite":"^1.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-typescript":"^0.14.0",install:"^0.13.0",luxon:"^3.3.0",npm:"^9.6.3","p-retry":"^5.1.2","pre-commit":"^1.2.2","start-server-and-test":"^1.15.2",typescript:"^4.9.3",vite:"^4.0.0"},engines:{npm:">=8.0.0",node:">=18.0.0"},files:["dist","scripts","src","typings"],main:"./dist/interface.mjs",scripts:{start:"vite",build:"tsc && vite build --config vite.config.interface.ts && vite build --config vite.config.map.ts",watch:"node scripts/watch.mjs",preview:"vite preview",format:"prettier --write .",lint:"eslint --ext .js,.ts .","lint:fix":"eslint --ext .js,.ts . --fix",cypress:"start-server-and-test start 5173 'cypress open'",test:"start-server-and-test start 5173 'cypress run'"},"pre-commit":["format","lint:fix"]},d=new MessageChannel,i=d.port1;class b{constructor(e){y(this,"iframe");this.iframe=e}setData(e){i.postMessage({type:"setData",body:{data:e}})}setSignalsData(e){i.postMessage({type:"setSignalsData",body:{data:e}})}setSignalsEndpoint(e){i.postMessage({type:"setSignalsEndpoint",body:{options:e}})}setSignalsGeometry(e){i.postMessage({type:"setSignalsGeometry",body:{geometry:e}})}setOptions(e){i.postMessage({type:"setOptions",body:{options:e}})}getFoo(){return new Promise(e=>{const t=Date.now();i.onmessage=c=>{c.data.ts===t&&e(c.data.body)},i.postMessage({ts:t,type:"getFoo",body:"hello world"})})}}const w=r=>r?new Promise(e=>{var l,u;const t=document.createElement("iframe");if(t.style.cssText="width: 100%; height: 100%; display: block; margin: 0; border: none;",t.setAttribute("src",(l=typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||new URL("interface.umd.js",document.baseURI).href)!=null&&l.includes("localhost")?"http://localhost:5173/index.html":"about:blank"),t.setAttribute("id","EOxChart"),r==null||r.appendChild(t),!((u=typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||new URL("interface.umd.js",document.baseURI).href)!=null&&u.includes("localhost"))){const a=`https://www.unpkg.com/@eox/chart@${g.version}/dist`;fetch(`${a}/index.html`).then(p=>p.text()).then(p=>{var f,m,h;const x=p.replace("./assets/",`${a}/assets/`);(f=t.contentDocument)==null||f.open(),(m=t.contentDocument)==null||m.write(x),(h=t.contentDocument)==null||h.close()})}let c=!1;t.onload=()=>{var a;c||((a=t.contentWindow)==null||a.postMessage("init","*",[d.port2]),c=!0,e(new b(t)))}}):(console.error("no div selected"),null);n.createChart=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/scripts/watch.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createServer, build } from "vite";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
|
|
5
|
-
*/
|
|
6
|
-
function watchInterface(server) {
|
|
7
|
-
return build({
|
|
8
|
-
configFile: "vite.config.interface.ts",
|
|
9
|
-
mode: "development",
|
|
10
|
-
build: {
|
|
11
|
-
watch: {},
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
|
|
18
|
-
*/
|
|
19
|
-
function watchMain(server) {
|
|
20
|
-
return build({
|
|
21
|
-
configFile: "vite.config.map.ts",
|
|
22
|
-
mode: "development",
|
|
23
|
-
build: {
|
|
24
|
-
watch: {},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// bootstrap
|
|
30
|
-
const server = await createServer({ configFile: "vite.config.map.ts" });
|
|
31
|
-
|
|
32
|
-
await server.listen();
|
|
33
|
-
await watchInterface(server); // outputs to public/interface.js, so run first
|
|
34
|
-
await watchMain(server);
|
package/src/Chart.ce.vue
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="chartControls" id="controls" class="controls" data-cy="controls"></div>
|
|
3
|
-
<canvas ref="chartCanvas" id="chart" class="chart" data-cy="chart"></canvas>
|
|
4
|
-
</template>
|
|
5
|
-
|
|
6
|
-
<script setup lang="ts">
|
|
7
|
-
import { ref, onMounted } from 'vue'
|
|
8
|
-
import Chart, { ChartDataset } from "chart.js/auto";
|
|
9
|
-
import "chartjs-adapter-luxon";
|
|
10
|
-
import SignalsDataManager from "./signalsDataManager";
|
|
11
|
-
import ChartControls from "./chartControls";
|
|
12
|
-
|
|
13
|
-
const chartCanvas = ref(null)
|
|
14
|
-
const chartControls = ref(null)
|
|
15
|
-
const props = defineProps([
|
|
16
|
-
'data',
|
|
17
|
-
'options',
|
|
18
|
-
'signalsdata',
|
|
19
|
-
'signalsendpoint'
|
|
20
|
-
])
|
|
21
|
-
|
|
22
|
-
let eoxchart
|
|
23
|
-
let sdmInstance: SignalsDataManager | null = null;
|
|
24
|
-
|
|
25
|
-
onMounted(() => {
|
|
26
|
-
eoxchart = new Chart(
|
|
27
|
-
<HTMLCanvasElement>chartCanvas.value,
|
|
28
|
-
{
|
|
29
|
-
data: {
|
|
30
|
-
labels: [],
|
|
31
|
-
datasets: [],
|
|
32
|
-
},
|
|
33
|
-
plugins: [
|
|
34
|
-
{
|
|
35
|
-
id: "selectionLineHighlight",
|
|
36
|
-
afterDraw: (chart) => {
|
|
37
|
-
if (chart && chart.tooltip) {
|
|
38
|
-
const active = chart.tooltip.getActiveElements();
|
|
39
|
-
if (active?.length) {
|
|
40
|
-
let x = active[0].element.x;
|
|
41
|
-
let yAxis = chart.scales.y;
|
|
42
|
-
let ctx = chart.ctx;
|
|
43
|
-
ctx.save();
|
|
44
|
-
ctx.beginPath();
|
|
45
|
-
ctx.moveTo(x, yAxis.top);
|
|
46
|
-
ctx.lineTo(x, yAxis.bottom);
|
|
47
|
-
ctx.lineWidth = 1;
|
|
48
|
-
ctx.strokeStyle = "rgba(0, 0, 255, 0.4)";
|
|
49
|
-
ctx.stroke();
|
|
50
|
-
ctx.restore();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
// TODO remove timeout hack
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
if (props.data) {
|
|
61
|
-
eoxchart.data = JSON.parse(props.data)
|
|
62
|
-
}
|
|
63
|
-
if (props.signalsdata) {
|
|
64
|
-
eoxchart.data = {
|
|
65
|
-
datasets: Object.entries(JSON.parse(props.signalsdata)).map(
|
|
66
|
-
([key, item]): ChartDataset => {
|
|
67
|
-
return {
|
|
68
|
-
type: "line",
|
|
69
|
-
label: key,
|
|
70
|
-
data: <number[]>item,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (props.options) {
|
|
77
|
-
eoxchart.options = JSON.parse(props.options)
|
|
78
|
-
}
|
|
79
|
-
if (props.signalsendpoint) {
|
|
80
|
-
setSignalsEndpoint(JSON.parse(props.signalsendpoint));
|
|
81
|
-
}
|
|
82
|
-
eoxchart.update("none")
|
|
83
|
-
}, 0)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const setSignalsEndpoint = (options: {
|
|
87
|
-
source: string;
|
|
88
|
-
endpoint: string;
|
|
89
|
-
active: string[];
|
|
90
|
-
features: string[][];
|
|
91
|
-
geometry: object;
|
|
92
|
-
timeInterval: object;
|
|
93
|
-
startTime?: string;
|
|
94
|
-
endTime?: string;
|
|
95
|
-
}) => {
|
|
96
|
-
sdmInstance = new SignalsDataManager(eoxchart, options);
|
|
97
|
-
new ChartControls(chartControls.value, sdmInstance, options);
|
|
98
|
-
sdmInstance.setActiveFields(options.active);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const setSignalsGeometry = (geometry: object) => {
|
|
102
|
-
if (sdmInstance) {
|
|
103
|
-
sdmInstance.setGeometry(geometry);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// export default {
|
|
109
|
-
// props: {
|
|
110
|
-
// data: String,
|
|
111
|
-
// },
|
|
112
|
-
// data: () => ({
|
|
113
|
-
// eoxchart: undefined
|
|
114
|
-
// }),
|
|
115
|
-
// computed: {
|
|
116
|
-
// parsedData() {
|
|
117
|
-
// if (!this.data) {
|
|
118
|
-
// return
|
|
119
|
-
// }
|
|
120
|
-
// return JSON.parse(this.data)
|
|
121
|
-
// }
|
|
122
|
-
// },
|
|
123
|
-
// watch: {
|
|
124
|
-
// parsedData(newData) {
|
|
125
|
-
// // setTimeout(() => {
|
|
126
|
-
// // this.eoxchart.data = newData
|
|
127
|
-
// // console.log(this.eoxchart.update)
|
|
128
|
-
// this.eoxchart.update();
|
|
129
|
-
// // }, 3000)
|
|
130
|
-
// }
|
|
131
|
-
// },
|
|
132
|
-
// mounted() {
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
</script>
|
|
136
|
-
|
|
137
|
-
<style>
|
|
138
|
-
* {
|
|
139
|
-
font-family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif";
|
|
140
|
-
font-size: 0.95em;
|
|
141
|
-
}
|
|
142
|
-
label {
|
|
143
|
-
margin-top: 2.5px;
|
|
144
|
-
}
|
|
145
|
-
html,
|
|
146
|
-
body {
|
|
147
|
-
margin: 0;
|
|
148
|
-
padding: 0;
|
|
149
|
-
}
|
|
150
|
-
html,
|
|
151
|
-
body,
|
|
152
|
-
.chart {
|
|
153
|
-
width: 100%;
|
|
154
|
-
height: 100%;
|
|
155
|
-
}
|
|
156
|
-
.hidden {
|
|
157
|
-
visibility: hidden;
|
|
158
|
-
}
|
|
159
|
-
.loader {
|
|
160
|
-
position: absolute;
|
|
161
|
-
top: 5px;
|
|
162
|
-
right: 30px;
|
|
163
|
-
width: 24px;
|
|
164
|
-
height: 24px;
|
|
165
|
-
border-radius: 50%;
|
|
166
|
-
display: inline-block;
|
|
167
|
-
border-top: 4px solid #000;
|
|
168
|
-
border-right: 4px solid transparent;
|
|
169
|
-
box-sizing: border-box;
|
|
170
|
-
animation: rotation 1s linear infinite;
|
|
171
|
-
}
|
|
172
|
-
.loader::after {
|
|
173
|
-
content: "";
|
|
174
|
-
box-sizing: border-box;
|
|
175
|
-
position: absolute;
|
|
176
|
-
left: 0;
|
|
177
|
-
top: 0;
|
|
178
|
-
width: 24px;
|
|
179
|
-
height: 24px;
|
|
180
|
-
border-radius: 50%;
|
|
181
|
-
border-left: 4px solid #004170;
|
|
182
|
-
border-bottom: 4px solid transparent;
|
|
183
|
-
animation: rotation 0.5s linear infinite reverse;
|
|
184
|
-
}
|
|
185
|
-
@keyframes rotation {
|
|
186
|
-
0% {
|
|
187
|
-
transform: rotate(0deg);
|
|
188
|
-
}
|
|
189
|
-
100% {
|
|
190
|
-
transform: rotate(360deg);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
#controls {
|
|
194
|
-
position: absolute;
|
|
195
|
-
width: 100%;
|
|
196
|
-
display: flex;
|
|
197
|
-
gap: 5px;
|
|
198
|
-
flex-direction: row;
|
|
199
|
-
}
|
|
200
|
-
.parsingError {
|
|
201
|
-
background-color: #ff6d6d;
|
|
202
|
-
}
|
|
203
|
-
#chart {
|
|
204
|
-
padding-top: 30px;
|
|
205
|
-
}
|
|
206
|
-
</style>
|
package/src/OLD_main.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import Chart, { ChartDataset } from "chart.js/auto";
|
|
2
|
-
import "chartjs-adapter-luxon";
|
|
3
|
-
import SignalsDataManager from "./signalsDataManager";
|
|
4
|
-
import ChartControls from "./chartControls";
|
|
5
|
-
|
|
6
|
-
const eoxchart = new Chart(
|
|
7
|
-
<HTMLCanvasElement>document.getElementById("chart"),
|
|
8
|
-
{
|
|
9
|
-
data: {
|
|
10
|
-
labels: [],
|
|
11
|
-
datasets: [],
|
|
12
|
-
},
|
|
13
|
-
plugins: [
|
|
14
|
-
{
|
|
15
|
-
id: "selectionLineHighlight",
|
|
16
|
-
afterDraw: (chart) => {
|
|
17
|
-
if (chart && chart.tooltip) {
|
|
18
|
-
const active = chart.tooltip.getActiveElements();
|
|
19
|
-
if (active?.length) {
|
|
20
|
-
let x = active[0].element.x;
|
|
21
|
-
let yAxis = chart.scales.y;
|
|
22
|
-
let ctx = chart.ctx;
|
|
23
|
-
ctx.save();
|
|
24
|
-
ctx.beginPath();
|
|
25
|
-
ctx.moveTo(x, yAxis.top);
|
|
26
|
-
ctx.lineTo(x, yAxis.bottom);
|
|
27
|
-
ctx.lineWidth = 1;
|
|
28
|
-
ctx.strokeStyle = "rgba(0, 0, 255, 0.4)";
|
|
29
|
-
ctx.stroke();
|
|
30
|
-
ctx.restore();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
let sdmInstance: SignalsDataManager | null = null;
|
|
40
|
-
|
|
41
|
-
let application: MessagePort;
|
|
42
|
-
|
|
43
|
-
window.addEventListener("message", (event) => {
|
|
44
|
-
if (event.data === "init") {
|
|
45
|
-
application = event.ports[0];
|
|
46
|
-
application.onmessage = onMessage;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const onMessage = (event: MessageEvent) => {
|
|
51
|
-
if (event.data.ts) {
|
|
52
|
-
switch (event.data.type) {
|
|
53
|
-
case "getFoo":
|
|
54
|
-
console.log(event.data.body);
|
|
55
|
-
application.postMessage({ ts: event.data.ts, body: "foo bar" });
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
switch (event.data.type) {
|
|
60
|
-
case "setData":
|
|
61
|
-
eoxchart.data = event.data.body.data;
|
|
62
|
-
eoxchart.update("none");
|
|
63
|
-
break;
|
|
64
|
-
case "setSignalsEndpoint":
|
|
65
|
-
setSignalsEndpoint(event.data.body.options);
|
|
66
|
-
break;
|
|
67
|
-
case "setSignalsGeometry":
|
|
68
|
-
setSignalsGeometry(event.data.body.geometry);
|
|
69
|
-
break;
|
|
70
|
-
case "setSignalsData":
|
|
71
|
-
eoxchart.data = {
|
|
72
|
-
datasets: Object.entries(event.data.body.data).map(
|
|
73
|
-
([key, item]): ChartDataset => {
|
|
74
|
-
return {
|
|
75
|
-
type: "line",
|
|
76
|
-
label: key,
|
|
77
|
-
data: <number[]>item,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
),
|
|
81
|
-
};
|
|
82
|
-
eoxchart.update("none");
|
|
83
|
-
break;
|
|
84
|
-
case "setOptions":
|
|
85
|
-
eoxchart.options = event.data.body.options;
|
|
86
|
-
eoxchart.update("none");
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const setSignalsEndpoint = (options: {
|
|
93
|
-
source: string;
|
|
94
|
-
endpoint: string;
|
|
95
|
-
active: string[];
|
|
96
|
-
features: string[][];
|
|
97
|
-
geometry: object;
|
|
98
|
-
timeInterval: object;
|
|
99
|
-
startTime?: string;
|
|
100
|
-
endTime?: string;
|
|
101
|
-
}) => {
|
|
102
|
-
sdmInstance = new SignalsDataManager(eoxchart, options);
|
|
103
|
-
new ChartControls(document.getElementById("controls"), sdmInstance, options);
|
|
104
|
-
sdmInstance.setActiveFields(options.active);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const setSignalsGeometry = (geometry: object) => {
|
|
108
|
-
if (sdmInstance) {
|
|
109
|
-
sdmInstance.setGeometry(geometry);
|
|
110
|
-
}
|
|
111
|
-
};
|