@eox/chart 1.2.0 → 1.2.2

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@eox/chart",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git@github.com:EOX-A/EOxElements.git"
8
8
  },
9
9
  "devDependencies": {
10
- "vite": "^8.0.10"
10
+ "vite": "^8.3.5"
11
11
  },
12
12
  "engines": {
13
13
  "npm": ">=8.0.0",
@@ -37,12 +37,12 @@
37
37
  "watch": "vite build --watch"
38
38
  },
39
39
  "dependencies": {
40
- "@eox/elements-utils": "^1.1.0",
40
+ "@eox/elements-utils": "^1.2.0",
41
41
  "@eox/ui": "^1.1.0",
42
- "deepmerge-ts": "^7.1.3",
43
- "lit": "^3.2.0",
44
- "vega": "^6.2.0",
45
- "vega-embed": "^7.1.0",
46
- "vega-lite": "^6.4.3"
42
+ "deepmerge-ts": "^8.0.2",
43
+ "lit": "^3.3.3",
44
+ "vega": "^6.4.0",
45
+ "vega-embed": "^7.3.0",
46
+ "vega-lite": "^6.5.0"
47
47
  }
48
48
  }
package/src/main.js CHANGED
@@ -65,16 +65,32 @@ export class EOxChart extends LitElement {
65
65
  /**
66
66
  * Renders the element without a shadow root
67
67
  *
68
- * @type {Boolean}
68
+ * @type {boolean}
69
69
  */
70
70
  this.noShadow = false;
71
71
 
72
72
  /**
73
73
  * Render the element without additional styles
74
74
  *
75
- * @type {Boolean}
75
+ * @type {boolean}
76
76
  */
77
77
  this.unstyled = false;
78
+
79
+ /**
80
+ * ResizeObserver instance to handle auto-resizing
81
+ *
82
+ * @type {ResizeObserver | null}
83
+ * @private
84
+ */
85
+ this._resizeObserver = null;
86
+
87
+ /**
88
+ * Vega view instance
89
+ *
90
+ * @type {any}
91
+ * @private
92
+ */
93
+ this._vegaView = null;
78
94
  }
79
95
 
80
96
  /**
@@ -120,10 +136,30 @@ export class EOxChart extends LitElement {
120
136
  }
121
137
  }
122
138
 
139
+ disconnectedCallback() {
140
+ super.disconnectedCallback();
141
+ if (this._resizeObserver) {
142
+ this._resizeObserver.disconnect();
143
+ }
144
+ }
145
+
123
146
  /**
124
147
  * Append custom styling for vega tooltip
125
148
  */
126
149
  firstUpdated() {
150
+ if (typeof ResizeObserver !== "undefined" && !this._resizeObserver) {
151
+ this._resizeObserver = new ResizeObserver(() => {
152
+ if (this._vegaView) {
153
+ window.dispatchEvent(new Event("resize"));
154
+ this._vegaView.resize().runAsync();
155
+ }
156
+ });
157
+ this._resizeObserver.observe(this);
158
+ if (this.parentElement) {
159
+ this._resizeObserver.observe(this.parentElement);
160
+ }
161
+ }
162
+
127
163
  if (!this.unstyled) {
128
164
  const style = document.createElement("style");
129
165
  style.innerHTML = `
@@ -1,3 +1,5 @@
1
+ const CHUNK_SIZE = 8192;
2
+
1
3
  /**
2
4
  * Encode object to base64 string
3
5
  * @param {import("vega-embed").VisualizationSpec} chartSpec
@@ -8,8 +10,12 @@ const base64EncodeSpec = (chartSpec) => {
8
10
  const json = JSON.stringify(chartSpec);
9
11
  const encoder = new TextEncoder();
10
12
  const data = encoder.encode(json);
11
- // @ts-expect-error Argument of type 'Uint8Array<ArrayBuffer>' is not assignable to parameter of type 'number[]'.
12
- const binaryString = String.fromCharCode.apply(null, data);
13
+ let binaryString = "";
14
+ for (let i = 0; i < data.length; i += CHUNK_SIZE) {
15
+ const chunk = data.subarray(i, i + CHUNK_SIZE);
16
+ // @ts-expect-error Argument of type 'Uint8Array' is not assignable to parameter of type 'number[]'.
17
+ binaryString += String.fromCharCode.apply(null, chunk);
18
+ }
13
19
  return btoa(binaryString);
14
20
  };
15
21
  export default base64EncodeSpec;
@@ -7,7 +7,7 @@ import { DEFAULT_SPEC, DEFAULT_OPT } from "../../enums";
7
7
  *
8
8
  * @param {import("../../main").EOxChart} EOxChart The eox-chart instance
9
9
  * @param {import("vega-embed").VisualizationSpec} spec
10
- * @param {Object=} dataValues
10
+ * @param {object=} dataValues
11
11
  *
12
12
  */
13
13
  const renderChartMethod = (EOxChart, spec, opt, dataValues) => {
@@ -34,6 +34,8 @@ const renderChartMethod = (EOxChart, spec, opt, dataValues) => {
34
34
  // @ts-expect-error using private method defined on EOxChart
35
35
  EOxChart._dispatchItemClickEvent({ event, item });
36
36
  });
37
+ // @ts-expect-error using private method defined on EOxChart
38
+ EOxChart._vegaView = res.view;
37
39
  });
38
40
  };
39
41
 
package/types/main.d.ts CHANGED
@@ -64,15 +64,29 @@ export class EOxChart extends LitElement {
64
64
  /**
65
65
  * Renders the element without a shadow root
66
66
  *
67
- * @type {Boolean}
67
+ * @type {boolean}
68
68
  */
69
69
  noShadow: boolean;
70
70
  /**
71
71
  * Render the element without additional styles
72
72
  *
73
- * @type {Boolean}
73
+ * @type {boolean}
74
74
  */
75
75
  unstyled: boolean;
76
+ /**
77
+ * ResizeObserver instance to handle auto-resizing
78
+ *
79
+ * @type {ResizeObserver | null}
80
+ * @private
81
+ */
82
+ private _resizeObserver;
83
+ /**
84
+ * Vega view instance
85
+ *
86
+ * @type {any}
87
+ * @private
88
+ */
89
+ private _vegaView;
76
90
  /**
77
91
  * @private
78
92
  */
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACE;;;;;;;;;;;;;;;;;MAME;IAKA;;;;OAIG;IACH,MAFU,OAAO,YAAY,EAAE,iBAAiB,GAAG,MAAM,CAEpC;IAErB;;;;OAIG;IACH,KAFU,OAAO,YAAY,EAAE,YAAY,CAEvB;IAEpB;;;;OAIG;IACH,YAFU;QAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,kCAAkC,EAAE,UAAU,CAAA;KAAC,GAAG,MAAM,CAEzE;IAE3B;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAGvB;;OAEG;IACH,sCAUC;IAED;;OAEG;IACH,gCAUC;IAED;;;;OAIG;IACH,2BAFW,OAAO,KAAK,EAAE,cAAc,iBAQtC;IAED;;OAEG;IACH,qBA6BC;IASD;;OAEG;IACH,+CAQC;CACF;2BA/KgC,KAAK;iCAKL,kBAAkB;0BADzB,kBAAkB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACE;;;;;;;;;;;;;;;;;MAME;IAKA;;;;OAIG;IACH,MAFU,OAAO,YAAY,EAAE,iBAAiB,GAAG,MAAM,CAEpC;IAErB;;;;OAIG;IACH,KAFU,OAAO,YAAY,EAAE,YAAY,CAEvB;IAEpB;;;;OAIG;IACH,YAFU;QAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,kCAAkC,EAAE,UAAU,CAAA;KAAC,GAAG,MAAM,CAEzE;IAE3B;;;;OAIG;IACH,UAFU,OAAO,CAEI;IAErB;;;;OAIG;IACH,UAFU,OAAO,CAEI;IAErB;;;;;OAKG;IACH,wBAA2B;IAE3B;;;;;OAKG;IACH,kBAAqB;IAGvB;;OAEG;IACH,sCAUC;IAED;;OAEG;IACH,gCAUC;IAED;;;;OAIG;IACH,2BAFW,OAAO,KAAK,EAAE,cAAc,iBAQtC;IASD;;OAEG;IACH,qBA0CC;IASD;;OAEG;IACH,+CAQC;CACF;2BAnNgC,KAAK;iCAKL,kBAAkB;0BADzB,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"encode-spec-b64.d.ts","sourceRoot":"","sources":["../../../src/methods/encode/encode-spec-b64.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,6CAHW,OAAO,YAAY,EAAE,iBAAiB,GACpC,MAAM,CAUlB"}
1
+ {"version":3,"file":"encode-spec-b64.d.ts","sourceRoot":"","sources":["../../../src/methods/encode/encode-spec-b64.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,6CAHW,OAAO,YAAY,EAAE,iBAAiB,GACpC,MAAM,CAclB"}
@@ -4,8 +4,8 @@ export default renderChartMethod;
4
4
  *
5
5
  * @param {import("../../main").EOxChart} EOxChart The eox-chart instance
6
6
  * @param {import("vega-embed").VisualizationSpec} spec
7
- * @param {Object=} dataValues
7
+ * @param {object=} dataValues
8
8
  *
9
9
  */
10
- declare function renderChartMethod(EOxChart: import("../../main").EOxChart, spec: import("vega-embed").VisualizationSpec, opt: any, dataValues?: any | undefined): void;
10
+ declare function renderChartMethod(EOxChart: import("../../main").EOxChart, spec: import("vega-embed").VisualizationSpec, opt: any, dataValues?: object | undefined): void;
11
11
  //# sourceMappingURL=render-chart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-chart.d.ts","sourceRoot":"","sources":["../../../src/methods/render/render-chart.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,6CALW,OAAO,YAAY,EAAE,QAAQ,QAC7B,OAAO,YAAY,EAAE,iBAAiB,yBACtC,eAAO,QA4BjB"}
1
+ {"version":3,"file":"render-chart.d.ts","sourceRoot":"","sources":["../../../src/methods/render/render-chart.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,6CALW,OAAO,YAAY,EAAE,QAAQ,QAC7B,OAAO,YAAY,EAAE,iBAAiB,yBACtC,MAAM,YAAC,QA8BjB"}