@eox/chart 2.0.0-alpha9 → 2.0.0-beta2

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.
@@ -1,7 +1,7 @@
1
1
  var f = Object.defineProperty;
2
2
  var x = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
3
  var h = (s, t, e) => (x(s, typeof t != "symbol" ? t + "" : t, e), e);
4
- const b = "@eox/chart", w = "2.0.0-alpha9", v = {
4
+ const b = "@eox/chart", w = "2.0.0-alpha8", v = {
5
5
  "chart.js": "^4.2.1",
6
6
  "chartjs-adapter-luxon": "^1.3.1",
7
7
  "chartjs-chart-error-bars": "^4.1.2"
@@ -1 +1 @@
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-alpha9",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"})});
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-alpha8",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/package.json CHANGED
@@ -1,27 +1,16 @@
1
1
  {
2
2
  "name": "@eox/chart",
3
- "version": "2.0.0-alpha9",
3
+ "version": "2.0.0-beta2",
4
+ "type": "module",
4
5
  "dependencies": {
5
6
  "chart.js": "^4.2.1",
6
7
  "chartjs-adapter-luxon": "^1.3.1",
7
8
  "chartjs-chart-error-bars": "^4.1.2"
8
9
  },
9
10
  "devDependencies": {
10
- "@eox/eslint-config": "^1.0.0",
11
11
  "@types/luxon": "^3.2.0",
12
- "@typescript-eslint/eslint-plugin": "^5.50.0",
13
- "@typescript-eslint/parser": "^5.50.0",
14
- "cypress": "^12.6.0",
15
- "cypress-vite": "^1.3.0",
16
- "eslint-plugin-cypress": "^2.12.1",
17
- "eslint-plugin-typescript": "^0.14.0",
18
- "install": "^0.13.0",
19
12
  "luxon": "^3.3.0",
20
- "npm": "^9.6.3",
21
13
  "p-retry": "^5.1.2",
22
- "pre-commit": "^1.2.2",
23
- "start-server-and-test": "^1.15.2",
24
- "typescript": "^4.9.3",
25
14
  "vite": "^4.0.0"
26
15
  },
27
16
  "engines": {
@@ -30,24 +19,12 @@
30
19
  },
31
20
  "files": [
32
21
  "dist",
33
- "scripts",
34
- "src",
35
- "typings"
22
+ "test"
36
23
  ],
37
- "main": "./dist/interface.mjs",
24
+ "main": "./dist/eox-chart.js",
38
25
  "scripts": {
39
26
  "start": "vite",
40
- "build": "tsc && vite build --config vite.config.interface.ts && vite build --config vite.config.map.ts",
41
- "watch": "node scripts/watch.mjs",
42
- "preview": "vite preview",
43
- "format": "prettier --write .",
44
- "lint": "eslint --ext .js,.ts .",
45
- "lint:fix": "eslint --ext .js,.ts . --fix",
46
- "cypress": "start-server-and-test start 5173 'cypress open'",
47
- "test": "start-server-and-test start 5173 'cypress run'"
48
- },
49
- "pre-commit": [
50
- "format",
51
- "lint:fix"
52
- ]
27
+ "build": "tsc && vite build",
28
+ "watch": "tsc && vite build --watch"
29
+ }
53
30
  }
@@ -0,0 +1,36 @@
1
+ import { EOxChart } from "../src/main";
2
+
3
+ describe("Chart", () => {
4
+ beforeEach(() => {
5
+ cy.visit("/elements/chart/test/general.html");
6
+ });
7
+
8
+ it("should expose the chart object", () => {
9
+ cy.get("eox-chart").should(($el) => {
10
+ const eoxChart = <EOxChart>$el[0];
11
+ expect(eoxChart.chart).to.exist;
12
+ });
13
+ });
14
+
15
+ it("loads the chart", () => {
16
+ cy.get("eox-chart").should(($el) => {
17
+ const eoxChart = <EOxChart>$el[0];
18
+ const data = {
19
+ datasets: [
20
+ {
21
+ type: "bar",
22
+ label: "Bar Dataset",
23
+ data: [1, 2, 3, 4],
24
+ },
25
+ {
26
+ type: "line",
27
+ label: "Line Dataset",
28
+ data: [6, 6, 6, 6],
29
+ },
30
+ ],
31
+ labels: ["January", "February", "March", "April"],
32
+ };
33
+ eoxChart.setData(data);
34
+ });
35
+ });
36
+ });
@@ -1,23 +1,19 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta charset="UTF-8" />
5
- <title>Simple Chart</title>
6
4
  <style>
7
- html,
8
- body {
9
- margin: 0;
10
- padding: 0;
11
- }
12
5
  html,
13
6
  body,
14
- .chart {
7
+ eox-chart {
8
+ padding: 0;
9
+ margin: 0;
15
10
  width: 100%;
16
11
  height: 100%;
17
12
  }
18
13
  </style>
14
+ <script type="module" defer src="../dist/eox-chart.js"></script>
19
15
  </head>
20
16
  <body>
21
- <div id="chart" class="chart" data-cy="chart"></div>
17
+ <eox-chart id="chart" class="chart"></eox-chart>
22
18
  </body>
23
19
  </html>
@@ -0,0 +1,37 @@
1
+ import { EOxChart } from "../src/main";
2
+
3
+ describe("SH Display", () => {
4
+ beforeEach(() => {
5
+ cy.visit("/elements/chart/test/general.html");
6
+ });
7
+ it("configures signals endpoint for chart to retrieve data", () => {
8
+ cy.get("eox-chart").should(($el) => {
9
+ const eoxChart = <EOxChart>$el[0];
10
+
11
+ const options = {
12
+ endpoint:
13
+ "https://xcube-geodb.brockmann-consult.de/gtif/f0ad1e25-98fa-4b82-9228-815ab24f5dd1",
14
+ source: "GTIF",
15
+ table: "no2_data",
16
+ timeParameter: "date",
17
+ features: [["no2_ec_station_ppbv"]],
18
+ colors: [
19
+ "#ff0029",
20
+ "#377eb8",
21
+ "#66a61e",
22
+ "#984ea3",
23
+ "#00d2d5",
24
+ "#ff7f00",
25
+ "#af8d00",
26
+ ],
27
+ active: ["no2_ec_station_ppbv"],
28
+ timeInterval: {
29
+ months: 3,
30
+ },
31
+ startTime: "2022-01-01",
32
+ endTime: "2022-03-30",
33
+ };
34
+ eoxChart.setGeoDBEndpoint(options);
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,184 @@
1
+ // @ts-nocheck
2
+ import { EOxChart } from "../src/main";
3
+
4
+ describe("SH Display", () => {
5
+ beforeEach(() => {
6
+ cy.visit("/elements/chart/test/general.html");
7
+ });
8
+ it("configures signals endpoint for chart to retrieve data", () => {
9
+ cy.get("eox-chart").should(($el) => {
10
+ const eoxChart = <EOxChart>$el[0];
11
+
12
+ const options = {
13
+ endpoint:
14
+ "https://prototype-gftb1dhets8kbrfhr3zdka.ddc.hub.eox.at/eo-signals-api/eo-signals-for-geometry",
15
+ source: "sentinelhub",
16
+ features: [
17
+ [
18
+ "s1_rvi",
19
+ "s2_ndvi",
20
+ "s2_ndwi",
21
+ "s2_mndwi",
22
+ "s2_nddi",
23
+ "s2_ndmi",
24
+ "s2_nbsi",
25
+ "s2_evi",
26
+ "s2_savi",
27
+ "meteo_spei",
28
+ "meteo_pni",
29
+ "meteo_spi",
30
+ ],
31
+ ["s2_vci"],
32
+ ["modis_ndvi", "modis_ndwi", "modis_savi", "modis_evi", "modis_nddi"],
33
+ ["s3_ndvi", "s3_otci", "s2_lai", "s2_fapar"],
34
+ ["eto", "temp_min", "temp_avg", "temp_max", "prec"],
35
+ ],
36
+ additionalYAxis: [
37
+ {
38
+ id: "temperature",
39
+ containedSignals: ["temp_min", "temp_avg", "temp_max"],
40
+ },
41
+ {
42
+ id: "precipitation",
43
+ containedSignals: ["prec"],
44
+ },
45
+ ],
46
+ additionalYAxis: [
47
+ {
48
+ id: "add1",
49
+ containedSignals: ["modis_ndwi"],
50
+ },
51
+ {
52
+ id: "add2",
53
+ containedSignals: ["modis_savi"],
54
+ },
55
+ ],
56
+ additionalYAxis: [
57
+ {
58
+ id: "add1",
59
+ containedSignals: ["modis_ndwi"],
60
+ },
61
+ {
62
+ id: "add2",
63
+ containedSignals: ["modis_savi"],
64
+ },
65
+ ],
66
+ colors: [
67
+ "#ff0029",
68
+ "#377eb8",
69
+ "#66a61e",
70
+ "#984ea3",
71
+ "#00d2d5",
72
+ "#ff7f00",
73
+ "#af8d00",
74
+ "#7f80cd",
75
+ "#b3e900",
76
+ "#c42e60",
77
+ "#a65628",
78
+ "#f781bf",
79
+ "#8dd3c7",
80
+ "#bebada",
81
+ "#fb8072",
82
+ "#80b1d3",
83
+ "#fdb462",
84
+ "#fccde5",
85
+ "#bc80bd",
86
+ "#ffed6f",
87
+ "#c4eaff",
88
+ "#cf8c00",
89
+ "#1976D2",
90
+ "#0288D1",
91
+ "#757575",
92
+ "#ff5722",
93
+ "#303f9f",
94
+ ],
95
+ // retries: 5,
96
+ // normalize: true,
97
+ active: ["modis_ndvi", "modis_ndwi", "modis_savi"],
98
+ // timeAggregation: { week: 1 },
99
+ timeInterval: {
100
+ months: 3,
101
+ },
102
+ startTime: "2023-01-01",
103
+ endTime: "2023-03-30",
104
+ geometry: {
105
+ type: "Polygon",
106
+ coordinates: [
107
+ [
108
+ [20.13079927, 47.10302768],
109
+ [20.13084045, 47.1028265],
110
+ [20.1358676, 47.10146968],
111
+ [20.13740927, 47.10014585],
112
+ [20.13947607, 47.09893601],
113
+ [20.14091366, 47.09999145],
114
+ [20.1449318, 47.10150223],
115
+ [20.14791146, 47.10230676],
116
+ [20.15021132, 47.10395088],
117
+ [20.15405271, 47.10427089],
118
+ [20.15892741, 47.10398568],
119
+ [20.15852441, 47.10137122],
120
+ [20.15762095, 47.09983277],
121
+ [20.15739972, 47.0975736],
122
+ [20.15803736, 47.09471102],
123
+ [20.16078555, 47.09278008],
124
+ [20.16202649, 47.09216975],
125
+ [20.15674646, 47.08971359],
126
+ [20.14955762, 47.08650222],
127
+ [20.13871746, 47.08287273],
128
+ [20.13206638, 47.08157835],
129
+ [20.12726444, 47.08162372],
130
+ [20.12231283, 47.0824622],
131
+ [20.11401767, 47.08174784],
132
+ [20.11216468, 47.08018127],
133
+ [20.10948393, 47.07862235],
134
+ [20.10265513, 47.07664915],
135
+ [20.09653792, 47.07715786],
136
+ [20.08739187, 47.07520495],
137
+ [20.08127912, 47.07681145],
138
+ [20.07655974, 47.08095206],
139
+ [20.06658042, 47.07842296],
140
+ [20.05716056, 47.0777923],
141
+ [20.05220315, 47.08017979],
142
+ [20.04630443, 47.08419526],
143
+ [20.04133418, 47.08864202],
144
+ [20.03220524, 47.08935493],
145
+ [20.03172385, 47.09164789],
146
+ [20.03114258, 47.09606486],
147
+ [20.03149467, 47.09719311],
148
+ [20.03319485, 47.09955417],
149
+ [20.03803622, 47.10154872],
150
+ [20.04451973, 47.10273689],
151
+ [20.04782854, 47.10248179],
152
+ [20.05408279, 47.1002776],
153
+ [20.05902427, 47.09876342],
154
+ [20.06282968, 47.0985035],
155
+ [20.06912826, 47.09867377],
156
+ [20.07212495, 47.0994389],
157
+ [20.08114396, 47.10320425],
158
+ [20.08584159, 47.10621624],
159
+ [20.08800841, 47.10687536],
160
+ [20.09697203, 47.10769864],
161
+ [20.10840521, 47.10770649],
162
+ [20.12110234, 47.10464688],
163
+ [20.12769884, 47.1031142],
164
+ [20.13079927, 47.10302768],
165
+ ],
166
+ ],
167
+ },
168
+ };
169
+ eoxChart.setSignalsEndpoint(options);
170
+ });
171
+ cy.viewport(800, 700);
172
+ cy.wait(2000);
173
+ cy.viewport(600, 700);
174
+ cy.wait(2000);
175
+ cy.viewport(400, 700);
176
+ cy.wait(2000);
177
+ cy.viewport(800, 400);
178
+ cy.wait(2000);
179
+ cy.viewport(600, 400);
180
+ cy.wait(2000);
181
+ cy.viewport(400, 400);
182
+ cy.wait(2000);
183
+ });
184
+ });