@eox/chart 0.4.0 → 1.0.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/chart",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "vite": "^6.0.3"
@@ -27,12 +27,14 @@
27
27
  }
28
28
  },
29
29
  "scripts": {
30
- "prepack": "tsc --project tsconfig.build.json || true",
30
+ "types:generate": "tsc --project tsconfig.build.json || true",
31
+ "prepack": "npm run types:generate",
31
32
  "build": "vite build",
32
33
  "watch": "vite build --watch"
33
34
  },
34
35
  "dependencies": {
35
- "@eox/elements-utils": "^0.1.5",
36
+ "@eox/elements-utils": "^1.0.0",
37
+ "@eox/ui": "^0.3.6",
36
38
  "deepmerge-ts": "^7.1.3",
37
39
  "lit": "^3.2.0",
38
40
  "vega": "^5.30.0",
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @type {import("vega-embed").EmbedOptions}
3
+ */
4
+ export const DEFAULT_OPT = {
5
+ actions: false,
6
+ };
@@ -8,4 +8,5 @@ export const DEFAULT_SPEC = {
8
8
  height: "container",
9
9
  autosize: "fit",
10
10
  resize: true,
11
+ padding: 16,
11
12
  };
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_SPEC } from "./default-spec";
2
+ export { DEFAULT_OPT } from "./default-opt";
2
3
 
3
4
  export { TEST_SELECTORS, TEST_VALUES } from "./test";
package/src/main.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { LitElement, html } from "lit";
2
2
  import { style } from "./style";
3
3
  import { styleEOX } from "./style.eox";
4
- import allStyle from "@eox/elements-utils/styles/dist/all.style";
5
4
  import { renderChartMethod } from "./methods/render";
6
5
 
7
6
  /**
@@ -16,6 +15,7 @@ export class EOxChart extends LitElement {
16
15
  static properties = {
17
16
  dataValues: { attribute: false, type: Object },
18
17
  spec: { attribute: false, type: Object },
18
+ opt: { attribute: false, type: Object },
19
19
  noShadow: { attribute: "no-shadow", type: Boolean },
20
20
  unstyled: { type: Boolean },
21
21
  };
@@ -30,6 +30,13 @@ export class EOxChart extends LitElement {
30
30
  */
31
31
  this.spec = undefined;
32
32
 
33
+ /**
34
+ * [Vega-Embed options](https://github.com/vega/vega-embed?tab=readme-ov-file#options)
35
+ *
36
+ * @type {import("vega-embed").EmbedOptions}
37
+ */
38
+ this.opt = undefined;
39
+
33
40
  /**
34
41
  * Data values passed on runtime. Requires a [named data source](https://vega.github.io/vega-lite/docs/data.html#named) in the provided `spec`
35
42
  *
@@ -85,7 +92,41 @@ export class EOxChart extends LitElement {
85
92
  */
86
93
  async updated(changedProperties) {
87
94
  if (changedProperties.has("spec") || changedProperties.has("dataValues")) {
88
- renderChartMethod(this, this.spec, this.dataValues);
95
+ renderChartMethod(this, this.spec, this.opt, this.dataValues);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Append custom styling for vega tooltip
101
+ */
102
+ firstUpdated() {
103
+ if (!this.unstyled) {
104
+ const style = document.createElement("style");
105
+ style.innerHTML = `
106
+ #vg-tooltip-element {
107
+ margin: 0;
108
+ padding: 1rem 1rem 1rem 2rem;
109
+ border-radius: 0.5rem;
110
+ background-color: var(--inverse-surface);
111
+ box-shadow: 0 0.25rem 0.5rem 0 rgb(0 0 0 / 0.4);
112
+ line-height: normal;
113
+ white-space: normal;
114
+ border: none;
115
+ }
116
+ #vg-tooltip-element,
117
+ #vg-tooltip-element table {
118
+ font-size: small;
119
+ }
120
+ #vg-tooltip-element,
121
+ #vg-tooltip-element table tr td.key,
122
+ #vg-tooltip-element table tr td.value {
123
+ color: var(--inverse-on-surface);
124
+ }
125
+ #vg-tooltip-element table tr td.key {
126
+ font-weight: bold;
127
+ }
128
+ `;
129
+ document.head.appendChild(style);
89
130
  }
90
131
  }
91
132
 
@@ -103,10 +144,9 @@ export class EOxChart extends LitElement {
103
144
  return html`
104
145
  <style>
105
146
  ${style}
106
- ${!this.unstyled && allStyle}
107
147
  ${!this.unstyled && styleEOX}
108
148
  </style>
109
- <div id="vis"></div>
149
+ <div id="vis" class="no-round"></div>
110
150
  `;
111
151
  }
112
152
  }
@@ -1,6 +1,6 @@
1
1
  import { default as vegaEmbed } from "vega-embed";
2
2
  import { deepmerge } from "deepmerge-ts";
3
- import { DEFAULT_SPEC } from "../../enums";
3
+ import { DEFAULT_SPEC, DEFAULT_OPT } from "../../enums";
4
4
 
5
5
  /**
6
6
  * Render the Vega-Lite chart using vega-embed with a spec and (optionally) dataValues
@@ -10,11 +10,13 @@ import { DEFAULT_SPEC } from "../../enums";
10
10
  * @param {Object=} dataValues
11
11
  *
12
12
  */
13
- const renderChartMethod = (EOxChart, spec, dataValues) => {
13
+ const renderChartMethod = (EOxChart, spec, opt, dataValues) => {
14
14
  const mergedSpec = deepmerge(DEFAULT_SPEC, spec);
15
+ const mergedOpt = deepmerge(DEFAULT_OPT, opt);
15
16
  vegaEmbed(
16
17
  /** @type {HTMLElement} */ (EOxChart.renderRoot.querySelector("#vis")),
17
18
  mergedSpec,
19
+ mergedOpt,
18
20
  ).then((res) => {
19
21
  if (dataValues) {
20
22
  Object.keys(dataValues).forEach((dataSourceName) => {
package/src/style.eox.js CHANGED
@@ -1,5 +1,39 @@
1
+ import eoxStyle from "@eox/ui/style.css?inline";
2
+ import { addCommonStylesheet } from "@eox/elements-utils";
3
+
4
+ addCommonStylesheet();
5
+
1
6
  export const styleEOX = `
2
- eox-chart {
3
- font-family: Roboto, sans-serif;
7
+ ${eoxStyle}
8
+ :host {
9
+ --padding: 0.5rem;
10
+ }
11
+ .vega-embed details {
12
+ position: absolute;
13
+ top: .5rem !important;
14
+ right: .5rem !important;
15
+ }
16
+ .vega-embed summary {
17
+ background: var(--primary) !important;
18
+ color: var(--on-primary) !important;
19
+ border: none !important;
20
+ }
21
+ .vega-embed .vega-actions {
22
+ background: var(--surface-container-lowest) !important;
23
+ color: var(--on-surface) !important;
24
+ }
25
+ .vega-embed .vega-actions a {
26
+ font-family: inherit !important;
27
+ font-weight: normal !important;
28
+ font-size: small !important;
29
+ color: var(--on-surface) !important;
30
+ padding: 0 var(--padding) !important;
31
+ justify-content: flex-start;
32
+ }
33
+ .vega-embed .vega-actions a:hover {
34
+ background: color-mix(in srgb, var(--surface) 80%, transparent) !important;
35
+ }
36
+ .vega-embed.has-actions {
37
+ padding-right: 0 !important;
4
38
  }
5
39
  `;
package/src/style.js CHANGED
@@ -6,4 +6,7 @@ export const style = `
6
6
  width: 100%;
7
7
  height: 100%;
8
8
  }
9
+ .vega-embed > details {
10
+ position: static;
11
+ }
9
12
  `;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {import("vega-embed").EmbedOptions}
3
+ */
4
+ export const DEFAULT_OPT: import("vega-embed").EmbedOptions;
5
+ //# sourceMappingURL=default-opt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-opt.d.ts","sourceRoot":"","sources":["../../src/enums/default-opt.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,0BAFU,OAAO,YAAY,EAAE,YAAY,CAIzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-spec.d.ts","sourceRoot":"","sources":["../../src/enums/default-spec.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,2BAFU,OAAO,YAAY,EAAE,iBAAiB,CAS9C"}
1
+ {"version":3,"file":"default-spec.d.ts","sourceRoot":"","sources":["../../src/enums/default-spec.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,2BAFU,OAAO,YAAY,EAAE,iBAAiB,CAU9C"}
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_SPEC } from "./default-spec";
2
+ export { DEFAULT_OPT } from "./default-opt";
2
3
  export { TEST_SELECTORS, TEST_VALUES } from "./test";
3
4
  //# sourceMappingURL=index.d.ts.map
package/types/main.d.ts CHANGED
@@ -16,6 +16,10 @@ export class EOxChart extends LitElement {
16
16
  attribute: boolean;
17
17
  type: ObjectConstructor;
18
18
  };
19
+ opt: {
20
+ attribute: boolean;
21
+ type: ObjectConstructor;
22
+ };
19
23
  noShadow: {
20
24
  attribute: string;
21
25
  type: BooleanConstructor;
@@ -30,6 +34,12 @@ export class EOxChart extends LitElement {
30
34
  * @type {import("vega-embed").VisualizationSpec}
31
35
  */
32
36
  spec: import("vega-embed").VisualizationSpec;
37
+ /**
38
+ * [Vega-Embed options](https://github.com/vega/vega-embed?tab=readme-ov-file#options)
39
+ *
40
+ * @type {import("vega-embed").EmbedOptions}
41
+ */
42
+ opt: import("vega-embed").EmbedOptions;
33
43
  /**
34
44
  * Data values passed on runtime. Requires a [named data source](https://vega.github.io/vega-lite/docs/data.html#named) in the provided `spec`
35
45
  *
@@ -58,6 +68,10 @@ export class EOxChart extends LitElement {
58
68
  * @param {import("lit").PropertyValues} changedProperties
59
69
  */
60
70
  updated(changedProperties: import("lit").PropertyValues): Promise<void>;
71
+ /**
72
+ * Append custom styling for vega tooltip
73
+ */
74
+ firstUpdated(): void;
61
75
  /**
62
76
  * Renders the component's HTML and CSS
63
77
  */
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH;IACE;;;;;;;;;;;;;;;;MAKE;IAKA;;;;OAIG;IACH,MAFU,OAAO,YAAY,EAAE,iBAAiB,CAE3B;IAErB;;;;OAIG;IACH,YAFU;QAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,0BAA0B,EAAE,UAAU,CAAA;KAAC,CAExD;IAE3B;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAGvB,iDAWC;IAED,2CAWC;IAED;;;;OAIG;IACH,2BAFW,OAAO,KAAK,EAAE,cAAc,iBAMtC;IASD;;OAEG;IACH,+CASC;CACF;2BA/GgC,KAAK"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH;IACE;;;;;;;;;;;;;;;;;;;;MAME;IAKA;;;;OAIG;IACH,MAFU,OAAO,YAAY,EAAE,iBAAiB,CAE3B;IAErB;;;;OAIG;IACH,KAFU,OAAO,YAAY,EAAE,YAAY,CAEvB;IAEpB;;;;OAIG;IACH,YAFU;QAAC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,0BAA0B,EAAE,UAAU,CAAA;KAAC,CAExD;IAE3B;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAGvB,iDAWC;IAED,2CAWC;IAED;;;;OAIG;IACH,2BAFW,OAAO,KAAK,EAAE,cAAc,iBAMtC;IAED;;OAEG;IACH,qBA6BC;IASD;;OAEG;IACH,+CAQC;CACF;2BAvJgC,KAAK"}
@@ -7,5 +7,5 @@ export default renderChartMethod;
7
7
  * @param {Object=} dataValues
8
8
  *
9
9
  */
10
- declare function renderChartMethod(EOxChart: import("../../main").EOxChart, spec: import("vega-embed").VisualizationSpec, dataValues?: any | undefined): void;
10
+ declare function renderChartMethod(EOxChart: import("../../main").EOxChart, spec: import("vega-embed").VisualizationSpec, opt: any, dataValues?: any | 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,sCAyBhD"}
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,QA0BjB"}
package/types/style.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const style: "\n :root, :host, eox-chart {\n display: block;\n }\n #vis {\n width: 100%;\n height: 100%;\n }\n";
1
+ export const style: "\n :root, :host, eox-chart {\n display: block;\n }\n #vis {\n width: 100%;\n height: 100%;\n }\n .vega-embed > details {\n position: static;\n }\n";
2
2
  //# sourceMappingURL=style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.js"],"names":[],"mappings":"AAAA,oIAQE"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.js"],"names":[],"mappings":"AAAA,2LAWE"}
@@ -1,2 +1,2 @@
1
- export const styleEOX: "\n eox-chart {\n font-family: Roboto, sans-serif;\n }\n";
1
+ export const styleEOX: string;
2
2
  //# sourceMappingURL=style.eox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"AAAA,sFAIE"}
1
+ {"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"AAKA,8BAiCE"}