@eox/chart 0.3.1 → 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/dist/eox-chart.js +16759 -16752
- package/dist/eox-chart.umd.cjs +116 -34
- package/dist/material-symbols-outlined.woff2 +0 -0
- package/dist/material-symbols-rounded.woff2 +0 -0
- package/dist/material-symbols-sharp.woff2 +0 -0
- package/dist/material-symbols-subset.woff2 +0 -0
- package/package.json +5 -3
- package/src/enums/default-opt.js +6 -0
- package/src/enums/default-spec.js +1 -0
- package/src/enums/index.js +1 -0
- package/src/main.js +70 -4
- package/src/methods/render/render-chart.js +12 -2
- package/src/style.eox.js +36 -2
- package/src/style.js +3 -0
- package/types/enums/default-opt.d.ts +5 -0
- package/types/enums/default-opt.d.ts.map +1 -0
- package/types/enums/default-spec.d.ts.map +1 -1
- package/types/enums/index.d.ts +1 -0
- package/types/main.d.ts +16 -0
- package/types/main.d.ts.map +1 -1
- package/types/methods/render/render-chart.d.ts +1 -1
- package/types/methods/render/render-chart.d.ts.map +1 -1
- package/types/style.d.ts +1 -1
- package/types/style.d.ts.map +1 -1
- package/types/style.eox.d.ts +1 -1
- package/types/style.eox.d.ts.map +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/chart",
|
|
3
|
-
"version": "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
|
-
"
|
|
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.
|
|
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",
|
package/src/enums/index.js
CHANGED
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
|
*
|
|
@@ -52,6 +59,32 @@ export class EOxChart extends LitElement {
|
|
|
52
59
|
this.unstyled = false;
|
|
53
60
|
}
|
|
54
61
|
|
|
62
|
+
_dispatchItemPointerMoveEvent(detail) {
|
|
63
|
+
/**
|
|
64
|
+
* Chart item is hovered. Event detail includes
|
|
65
|
+
* `event` (pointermove event) and `item` (the hovered item on the chart)
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
this.dispatchEvent(
|
|
69
|
+
new CustomEvent("pointermove:item", {
|
|
70
|
+
detail,
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_dispatchItemClickEvent(detail) {
|
|
76
|
+
/**
|
|
77
|
+
* Chart item is clicked. Event detail includes
|
|
78
|
+
* `event` (click event) and `item` (the clicked item on the chart)
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
this.dispatchEvent(
|
|
82
|
+
new CustomEvent("click:item", {
|
|
83
|
+
detail,
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
55
88
|
/**
|
|
56
89
|
* Lifecycle method called when the element is updated
|
|
57
90
|
*
|
|
@@ -59,7 +92,41 @@ export class EOxChart extends LitElement {
|
|
|
59
92
|
*/
|
|
60
93
|
async updated(changedProperties) {
|
|
61
94
|
if (changedProperties.has("spec") || changedProperties.has("dataValues")) {
|
|
62
|
-
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);
|
|
63
130
|
}
|
|
64
131
|
}
|
|
65
132
|
|
|
@@ -77,10 +144,9 @@ export class EOxChart extends LitElement {
|
|
|
77
144
|
return html`
|
|
78
145
|
<style>
|
|
79
146
|
${style}
|
|
80
|
-
${!this.unstyled && allStyle}
|
|
81
147
|
${!this.unstyled && styleEOX}
|
|
82
148
|
</style>
|
|
83
|
-
<div id="vis"></div>
|
|
149
|
+
<div id="vis" class="no-round"></div>
|
|
84
150
|
`;
|
|
85
151
|
}
|
|
86
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) => {
|
|
@@ -22,6 +24,14 @@ const renderChartMethod = (EOxChart, spec, dataValues) => {
|
|
|
22
24
|
});
|
|
23
25
|
res.view.run();
|
|
24
26
|
}
|
|
27
|
+
res.view.addEventListener("pointermove", (event, item) => {
|
|
28
|
+
if (!item) return;
|
|
29
|
+
EOxChart._dispatchItemPointerMoveEvent({ event, item });
|
|
30
|
+
});
|
|
31
|
+
res.view.addEventListener("click", (event, item) => {
|
|
32
|
+
if (!item) return;
|
|
33
|
+
EOxChart._dispatchItemClickEvent({ event, item });
|
|
34
|
+
});
|
|
25
35
|
});
|
|
26
36
|
};
|
|
27
37
|
|
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
|
-
|
|
3
|
-
|
|
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
|
@@ -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,
|
|
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"}
|
package/types/enums/index.d.ts
CHANGED
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
|
*
|
|
@@ -50,12 +60,18 @@ export class EOxChart extends LitElement {
|
|
|
50
60
|
* @type {Boolean}
|
|
51
61
|
*/
|
|
52
62
|
unstyled: boolean;
|
|
63
|
+
_dispatchItemPointerMoveEvent(detail: any): void;
|
|
64
|
+
_dispatchItemClickEvent(detail: any): void;
|
|
53
65
|
/**
|
|
54
66
|
* Lifecycle method called when the element is updated
|
|
55
67
|
*
|
|
56
68
|
* @param {import("lit").PropertyValues} changedProperties
|
|
57
69
|
*/
|
|
58
70
|
updated(changedProperties: import("lit").PropertyValues): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Append custom styling for vega tooltip
|
|
73
|
+
*/
|
|
74
|
+
firstUpdated(): void;
|
|
59
75
|
/**
|
|
60
76
|
* Renders the component's HTML and CSS
|
|
61
77
|
*/
|
package/types/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"
|
|
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,
|
|
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
|
package/types/style.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.js"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.js"],"names":[],"mappings":"AAAA,2LAWE"}
|
package/types/style.eox.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const styleEOX:
|
|
1
|
+
export const styleEOX: string;
|
|
2
2
|
//# sourceMappingURL=style.eox.d.ts.map
|
package/types/style.eox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"AAKA,8BAiCE"}
|