nuxt-echarts 0.0.1 → 0.0.3
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 +31 -12
- package/dist/module.json +4 -1
- package/dist/module.mjs +18 -2
- package/dist/runtime/VChart.d.ts +314 -0
- package/dist/runtime/VChart.mjs +238 -0
- package/dist/runtime/composables/api.d.ts +7 -0
- package/dist/runtime/composables/api.mjs +35 -0
- package/dist/runtime/composables/autoresize.d.ts +11 -0
- package/dist/runtime/composables/autoresize.mjs +26 -0
- package/dist/runtime/composables/index.d.ts +3 -0
- package/dist/runtime/composables/index.mjs +3 -0
- package/dist/runtime/composables/loading.d.ts +8 -0
- package/dist/runtime/composables/loading.mjs +29 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.mjs +3 -0
- package/dist/runtime/plugin.mjs +0 -1
- package/dist/runtime/style.css +1 -0
- package/dist/runtime/types.d.ts +53 -0
- package/dist/runtime/types.mjs +0 -0
- package/dist/runtime/utils.d.ts +4 -0
- package/dist/runtime/utils.mjs +11 -0
- package/dist/runtime/wc.d.ts +6 -0
- package/dist/runtime/wc.mjs +30 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# Nuxt ECharts
|
|
2
4
|
|
|
3
5
|
[![npm version][npm-version-src]][npm-version-href]
|
|
@@ -15,13 +17,13 @@ Nuxt Module for Apache ECharts™
|
|
|
15
17
|
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/nuxt-echarts?file=playground%2Fapp.vue) -->
|
|
16
18
|
<!-- - [📖 Documentation](https://example.com) -->
|
|
17
19
|
|
|
18
|
-
## Features
|
|
20
|
+
## Features (WIP)
|
|
19
21
|
|
|
20
22
|
<!-- Highlight some of the features your module provide here -->
|
|
21
23
|
|
|
22
|
-
- ⛰
|
|
23
|
-
-
|
|
24
|
-
-
|
|
24
|
+
- ⛰ **SSR**: experimental server-only component, lightweight client runtime
|
|
25
|
+
- 🛠️ **Configurable**: import only necessary components and charts for smaller bundle size
|
|
26
|
+
- 🦾 **Type Strong**: generate ECharts option type based on your config
|
|
25
27
|
|
|
26
28
|
## Quick Setup
|
|
27
29
|
|
|
@@ -40,30 +42,47 @@ That's it! You can now use Nuxt ECharts in your Nuxt app ✨
|
|
|
40
42
|
|
|
41
43
|
```bash
|
|
42
44
|
# Install dependencies
|
|
43
|
-
|
|
45
|
+
pnpm install
|
|
44
46
|
|
|
45
47
|
# Generate type stubs
|
|
46
|
-
|
|
48
|
+
pnpm run dev:prepare
|
|
47
49
|
|
|
48
50
|
# Develop with the playground
|
|
49
|
-
|
|
51
|
+
pnpm run dev
|
|
50
52
|
|
|
51
53
|
# Build the playground
|
|
52
|
-
|
|
54
|
+
pnpm run dev:build
|
|
53
55
|
|
|
54
56
|
# Run ESLint
|
|
55
|
-
|
|
57
|
+
pnpm run lint
|
|
58
|
+
|
|
59
|
+
# Format with Prettier
|
|
60
|
+
pnpm run format
|
|
56
61
|
|
|
57
62
|
# Run Vitest
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
pnpm run test
|
|
64
|
+
pnpm run test:watch
|
|
60
65
|
|
|
61
66
|
# Release new version
|
|
62
|
-
|
|
67
|
+
pnpm run release
|
|
63
68
|
```
|
|
64
69
|
|
|
65
70
|
</details>
|
|
66
71
|
|
|
72
|
+
## Credits
|
|
73
|
+
|
|
74
|
+
The Nuxt ECharts module is heavily inspired by [vue-echarts](https://github.com/ecomfe/vue-echarts), created by[@Justineo](https://github.com/Justineo).
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
This project is licensed under the [MIT License](./LICENSE).
|
|
79
|
+
|
|
80
|
+
This project also partially contains code derived or copied from [vue-echarts(MIT)](https://github.com/ecomfe/vue-echarts/blob/main/LICENSE).
|
|
81
|
+
|
|
82
|
+
## Notice
|
|
83
|
+
|
|
84
|
+
The Apache Software Foundation [Apache ECharts, ECharts](https://echarts.apache.org/), Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the [Apache Software Foundation](https://www.apache.org/).
|
|
85
|
+
|
|
67
86
|
<!-- Badges -->
|
|
68
87
|
|
|
69
88
|
[npm-version-src]: https://img.shields.io/npm/v/nuxt-echarts/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponent, addImports } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
5
5
|
name: "nuxt-echarts",
|
|
6
|
-
configKey: "echarts"
|
|
6
|
+
configKey: "echarts",
|
|
7
|
+
compatibility: {
|
|
8
|
+
// Semver version of supported nuxt versions
|
|
9
|
+
nuxt: "^3.0.0"
|
|
10
|
+
}
|
|
7
11
|
},
|
|
8
12
|
// Default configuration options of the Nuxt module
|
|
9
13
|
defaults: {},
|
|
10
14
|
setup(_options, _nuxt) {
|
|
11
15
|
const resolver = createResolver(import.meta.url);
|
|
12
16
|
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
17
|
+
const entry = resolver.resolve("./runtime/VChart.ts");
|
|
18
|
+
addComponent({
|
|
19
|
+
name: "VChart",
|
|
20
|
+
filePath: entry
|
|
21
|
+
});
|
|
22
|
+
const injectionKeys = [
|
|
23
|
+
"THEME_KEY",
|
|
24
|
+
"INIT_OPTIONS_KEY",
|
|
25
|
+
"UPDATE_OPTIONS_KEY",
|
|
26
|
+
"LOADING_OPTIONS_KEY"
|
|
27
|
+
];
|
|
28
|
+
injectionKeys.forEach((name) => addImports({ name, from: entry }));
|
|
13
29
|
}
|
|
14
30
|
});
|
|
15
31
|
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { type PropType, type InjectionKey } from 'vue';
|
|
2
|
+
import type { Option, Theme, ThemeInjection, InitOptionsInjection, UpdateOptions, UpdateOptionsInjection } from './types';
|
|
3
|
+
import { type EChartsElement } from './wc';
|
|
4
|
+
import './style.css';
|
|
5
|
+
export declare const THEME_KEY: InjectionKey<ThemeInjection>;
|
|
6
|
+
export declare const INIT_OPTIONS_KEY: InjectionKey<InitOptionsInjection>;
|
|
7
|
+
export declare const UPDATE_OPTIONS_KEY: InjectionKey<UpdateOptionsInjection>;
|
|
8
|
+
export { LOADING_OPTIONS_KEY } from './composables';
|
|
9
|
+
declare const _default: import("vue").DefineComponent<{
|
|
10
|
+
loading: BooleanConstructor;
|
|
11
|
+
loadingOptions: PropType<import("./types").LoadingOptions>;
|
|
12
|
+
autoresize: PropType<boolean | {
|
|
13
|
+
throttle?: number | undefined;
|
|
14
|
+
onResize?: (() => void) | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
option: PropType<import("echarts/core").EChartsCoreOption>;
|
|
17
|
+
theme: {
|
|
18
|
+
type: PropType<Theme>;
|
|
19
|
+
};
|
|
20
|
+
initOptions: PropType<import("echarts/core").EChartsInitOpts>;
|
|
21
|
+
updateOptions: PropType<import("echarts").SetOptionOpts>;
|
|
22
|
+
group: StringConstructor;
|
|
23
|
+
manualUpdate: BooleanConstructor;
|
|
24
|
+
}, {
|
|
25
|
+
getWidth: () => number;
|
|
26
|
+
getHeight: () => number;
|
|
27
|
+
getDom: () => HTMLElement;
|
|
28
|
+
getOption: () => import("echarts/core").EChartsCoreOption;
|
|
29
|
+
resize: (opts?: import("echarts/core").ResizeOpts | undefined) => void;
|
|
30
|
+
dispatchAction: (payload: import("echarts/core").Payload, opt?: boolean | {
|
|
31
|
+
silent?: boolean | undefined;
|
|
32
|
+
flush?: boolean | undefined;
|
|
33
|
+
} | undefined) => void;
|
|
34
|
+
convertToPixel: {
|
|
35
|
+
(finder: string | {
|
|
36
|
+
seriesIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
37
|
+
seriesId?: ((string | number) | (string | number)[]) | undefined;
|
|
38
|
+
seriesName?: ((string | number) | (string | number)[]) | undefined;
|
|
39
|
+
geoIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
40
|
+
geoId?: ((string | number) | (string | number)[]) | undefined;
|
|
41
|
+
geoName?: ((string | number) | (string | number)[]) | undefined;
|
|
42
|
+
bmapIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
43
|
+
bmapId?: ((string | number) | (string | number)[]) | undefined;
|
|
44
|
+
bmapName?: ((string | number) | (string | number)[]) | undefined;
|
|
45
|
+
xAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
46
|
+
xAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
47
|
+
xAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
48
|
+
yAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
49
|
+
yAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
50
|
+
yAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
51
|
+
gridIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
52
|
+
gridId?: ((string | number) | (string | number)[]) | undefined;
|
|
53
|
+
gridName?: ((string | number) | (string | number)[]) | undefined;
|
|
54
|
+
dataIndex?: number | undefined;
|
|
55
|
+
dataIndexInside?: number | undefined;
|
|
56
|
+
}, value: (string | number) | Date): number;
|
|
57
|
+
(finder: string | {
|
|
58
|
+
seriesIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
59
|
+
seriesId?: ((string | number) | (string | number)[]) | undefined;
|
|
60
|
+
seriesName?: ((string | number) | (string | number)[]) | undefined;
|
|
61
|
+
geoIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
62
|
+
geoId?: ((string | number) | (string | number)[]) | undefined;
|
|
63
|
+
geoName?: ((string | number) | (string | number)[]) | undefined;
|
|
64
|
+
bmapIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
65
|
+
bmapId?: ((string | number) | (string | number)[]) | undefined;
|
|
66
|
+
bmapName?: ((string | number) | (string | number)[]) | undefined;
|
|
67
|
+
xAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
68
|
+
xAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
69
|
+
xAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
70
|
+
yAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
71
|
+
yAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
72
|
+
yAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
73
|
+
gridIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
74
|
+
gridId?: ((string | number) | (string | number)[]) | undefined;
|
|
75
|
+
gridName?: ((string | number) | (string | number)[]) | undefined;
|
|
76
|
+
dataIndex?: number | undefined;
|
|
77
|
+
dataIndexInside?: number | undefined;
|
|
78
|
+
}, value: ((string | number) | Date)[]): number[];
|
|
79
|
+
};
|
|
80
|
+
convertFromPixel: {
|
|
81
|
+
(finder: string | {
|
|
82
|
+
seriesIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
83
|
+
seriesId?: ((string | number) | (string | number)[]) | undefined;
|
|
84
|
+
seriesName?: ((string | number) | (string | number)[]) | undefined;
|
|
85
|
+
geoIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
86
|
+
geoId?: ((string | number) | (string | number)[]) | undefined;
|
|
87
|
+
geoName?: ((string | number) | (string | number)[]) | undefined;
|
|
88
|
+
bmapIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
89
|
+
bmapId?: ((string | number) | (string | number)[]) | undefined;
|
|
90
|
+
bmapName?: ((string | number) | (string | number)[]) | undefined;
|
|
91
|
+
xAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
92
|
+
xAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
93
|
+
xAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
94
|
+
yAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
95
|
+
yAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
96
|
+
yAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
97
|
+
gridIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
98
|
+
gridId?: ((string | number) | (string | number)[]) | undefined;
|
|
99
|
+
gridName?: ((string | number) | (string | number)[]) | undefined;
|
|
100
|
+
dataIndex?: number | undefined;
|
|
101
|
+
dataIndexInside?: number | undefined;
|
|
102
|
+
}, value: number): number;
|
|
103
|
+
(finder: string | {
|
|
104
|
+
seriesIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
105
|
+
seriesId?: ((string | number) | (string | number)[]) | undefined;
|
|
106
|
+
seriesName?: ((string | number) | (string | number)[]) | undefined;
|
|
107
|
+
geoIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
108
|
+
geoId?: ((string | number) | (string | number)[]) | undefined;
|
|
109
|
+
geoName?: ((string | number) | (string | number)[]) | undefined;
|
|
110
|
+
bmapIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
111
|
+
bmapId?: ((string | number) | (string | number)[]) | undefined;
|
|
112
|
+
bmapName?: ((string | number) | (string | number)[]) | undefined;
|
|
113
|
+
xAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
114
|
+
xAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
115
|
+
xAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
116
|
+
yAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
117
|
+
yAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
118
|
+
yAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
119
|
+
gridIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
120
|
+
gridId?: ((string | number) | (string | number)[]) | undefined;
|
|
121
|
+
gridName?: ((string | number) | (string | number)[]) | undefined;
|
|
122
|
+
dataIndex?: number | undefined;
|
|
123
|
+
dataIndexInside?: number | undefined;
|
|
124
|
+
}, value: number[]): number[];
|
|
125
|
+
};
|
|
126
|
+
containPixel: (finder: string | {
|
|
127
|
+
seriesIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
128
|
+
seriesId?: ((string | number) | (string | number)[]) | undefined;
|
|
129
|
+
seriesName?: ((string | number) | (string | number)[]) | undefined;
|
|
130
|
+
geoIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
131
|
+
geoId?: ((string | number) | (string | number)[]) | undefined;
|
|
132
|
+
geoName?: ((string | number) | (string | number)[]) | undefined;
|
|
133
|
+
bmapIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
134
|
+
bmapId?: ((string | number) | (string | number)[]) | undefined;
|
|
135
|
+
bmapName?: ((string | number) | (string | number)[]) | undefined;
|
|
136
|
+
xAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
137
|
+
xAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
138
|
+
xAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
139
|
+
yAxisIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
140
|
+
yAxisId?: ((string | number) | (string | number)[]) | undefined;
|
|
141
|
+
yAxisName?: ((string | number) | (string | number)[]) | undefined;
|
|
142
|
+
gridIndex?: (number | false | number[] | "all" | "none") | undefined;
|
|
143
|
+
gridId?: ((string | number) | (string | number)[]) | undefined;
|
|
144
|
+
gridName?: ((string | number) | (string | number)[]) | undefined;
|
|
145
|
+
dataIndex?: number | undefined;
|
|
146
|
+
dataIndexInside?: number | undefined;
|
|
147
|
+
}, value: number[]) => boolean;
|
|
148
|
+
getDataURL: (opts?: {
|
|
149
|
+
type?: "svg" | "png" | "jpeg" | undefined;
|
|
150
|
+
pixelRatio?: number | undefined;
|
|
151
|
+
backgroundColor?: import("echarts/core").Color | undefined;
|
|
152
|
+
excludeComponents?: string[] | undefined;
|
|
153
|
+
} | undefined) => string;
|
|
154
|
+
getConnectedDataURL: (opts?: {
|
|
155
|
+
type?: "svg" | "png" | "jpeg" | undefined;
|
|
156
|
+
pixelRatio?: number | undefined;
|
|
157
|
+
backgroundColor?: import("echarts/core").Color | undefined;
|
|
158
|
+
connectedBackgroundColor?: import("echarts/core").Color | undefined;
|
|
159
|
+
excludeComponents?: string[] | undefined;
|
|
160
|
+
} | undefined) => string;
|
|
161
|
+
appendData: (params: {
|
|
162
|
+
seriesIndex: number;
|
|
163
|
+
data: any;
|
|
164
|
+
}) => void;
|
|
165
|
+
clear: () => void;
|
|
166
|
+
isDisposed: () => boolean;
|
|
167
|
+
dispose: () => void;
|
|
168
|
+
chart: import("vue").ShallowRef<import("echarts/core").ECharts | undefined>;
|
|
169
|
+
root: import("vue").ShallowRef<EChartsElement | undefined>;
|
|
170
|
+
inner: import("vue").ShallowRef<HTMLElement | undefined>;
|
|
171
|
+
setOption: (option: Option, updateOptions?: UpdateOptions) => void;
|
|
172
|
+
nonEventAttrs: import("vue").ComputedRef<{
|
|
173
|
+
[x: string]: any;
|
|
174
|
+
}>;
|
|
175
|
+
nativeListeners: Record<string, unknown>;
|
|
176
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
177
|
+
click: (params: import("echarts").ECElementEvent) => boolean;
|
|
178
|
+
dblclick: (params: import("echarts").ECElementEvent) => boolean;
|
|
179
|
+
mouseout: (params: import("echarts").ECElementEvent) => boolean;
|
|
180
|
+
mouseover: (params: import("echarts").ECElementEvent) => boolean;
|
|
181
|
+
mouseup: (params: import("echarts").ECElementEvent) => boolean;
|
|
182
|
+
mousedown: (params: import("echarts").ECElementEvent) => boolean;
|
|
183
|
+
mousemove: (params: import("echarts").ECElementEvent) => boolean;
|
|
184
|
+
contextmenu: (params: import("echarts").ECElementEvent) => boolean;
|
|
185
|
+
globalout: (params: import("echarts").ECElementEvent) => boolean;
|
|
186
|
+
} & {
|
|
187
|
+
highlight: null;
|
|
188
|
+
downplay: null;
|
|
189
|
+
selectchanged: null;
|
|
190
|
+
legendselectchanged: null;
|
|
191
|
+
legendselected: null;
|
|
192
|
+
legendunselected: null;
|
|
193
|
+
legendselectall: null;
|
|
194
|
+
legendinverseselect: null;
|
|
195
|
+
legendscroll: null;
|
|
196
|
+
datazoom: null;
|
|
197
|
+
datarangeselected: null;
|
|
198
|
+
graphroam: null;
|
|
199
|
+
georoam: null;
|
|
200
|
+
treeroam: null;
|
|
201
|
+
timelinechanged: null;
|
|
202
|
+
timelineplaychanged: null;
|
|
203
|
+
restore: null;
|
|
204
|
+
dataviewchanged: null;
|
|
205
|
+
magictypechanged: null;
|
|
206
|
+
geoselectchanged: null;
|
|
207
|
+
geoselected: null;
|
|
208
|
+
geounselected: null;
|
|
209
|
+
axisareaselected: null;
|
|
210
|
+
brush: null;
|
|
211
|
+
brushEnd: null;
|
|
212
|
+
brushselected: null;
|
|
213
|
+
globalcursortaken: null;
|
|
214
|
+
} & {
|
|
215
|
+
rendered: (params: {
|
|
216
|
+
elapsedTime: number;
|
|
217
|
+
}) => boolean;
|
|
218
|
+
finished: () => boolean;
|
|
219
|
+
} & {
|
|
220
|
+
"zr:mousewheel": (params: import("echarts").ElementEvent) => boolean;
|
|
221
|
+
"zr:drag": (params: import("echarts").ElementEvent) => boolean;
|
|
222
|
+
"zr:dragstart": (params: import("echarts").ElementEvent) => boolean;
|
|
223
|
+
"zr:dragend": (params: import("echarts").ElementEvent) => boolean;
|
|
224
|
+
"zr:dragenter": (params: import("echarts").ElementEvent) => boolean;
|
|
225
|
+
"zr:dragleave": (params: import("echarts").ElementEvent) => boolean;
|
|
226
|
+
"zr:dragover": (params: import("echarts").ElementEvent) => boolean;
|
|
227
|
+
"zr:drop": (params: import("echarts").ElementEvent) => boolean;
|
|
228
|
+
"zr:click": (params: import("echarts").ElementEvent) => boolean;
|
|
229
|
+
"zr:dblclick": (params: import("echarts").ElementEvent) => boolean;
|
|
230
|
+
"zr:mouseout": (params: import("echarts").ElementEvent) => boolean;
|
|
231
|
+
"zr:mouseover": (params: import("echarts").ElementEvent) => boolean;
|
|
232
|
+
"zr:mouseup": (params: import("echarts").ElementEvent) => boolean;
|
|
233
|
+
"zr:mousedown": (params: import("echarts").ElementEvent) => boolean;
|
|
234
|
+
"zr:mousemove": (params: import("echarts").ElementEvent) => boolean;
|
|
235
|
+
"zr:contextmenu": (params: import("echarts").ElementEvent) => boolean;
|
|
236
|
+
"zr:globalout": (params: import("echarts").ElementEvent) => boolean;
|
|
237
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
238
|
+
loading: BooleanConstructor;
|
|
239
|
+
loadingOptions: PropType<import("./types").LoadingOptions>;
|
|
240
|
+
autoresize: PropType<boolean | {
|
|
241
|
+
throttle?: number | undefined;
|
|
242
|
+
onResize?: (() => void) | undefined;
|
|
243
|
+
}>;
|
|
244
|
+
option: PropType<import("echarts/core").EChartsCoreOption>;
|
|
245
|
+
theme: {
|
|
246
|
+
type: PropType<Theme>;
|
|
247
|
+
};
|
|
248
|
+
initOptions: PropType<import("echarts/core").EChartsInitOpts>;
|
|
249
|
+
updateOptions: PropType<import("echarts").SetOptionOpts>;
|
|
250
|
+
group: StringConstructor;
|
|
251
|
+
manualUpdate: BooleanConstructor;
|
|
252
|
+
}>> & {
|
|
253
|
+
onClick?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
254
|
+
onDblclick?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
255
|
+
onMouseout?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
256
|
+
onMouseover?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
257
|
+
onMouseup?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
258
|
+
onMousedown?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
259
|
+
onMousemove?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
260
|
+
onContextmenu?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
261
|
+
onGlobalout?: ((params: import("echarts").ECElementEvent) => any) | undefined;
|
|
262
|
+
"onZr:mousewheel"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
263
|
+
"onZr:drag"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
264
|
+
"onZr:dragstart"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
265
|
+
"onZr:dragend"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
266
|
+
"onZr:dragenter"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
267
|
+
"onZr:dragleave"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
268
|
+
"onZr:dragover"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
269
|
+
"onZr:drop"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
270
|
+
"onZr:click"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
271
|
+
"onZr:dblclick"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
272
|
+
"onZr:mouseout"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
273
|
+
"onZr:mouseover"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
274
|
+
"onZr:mouseup"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
275
|
+
"onZr:mousedown"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
276
|
+
"onZr:mousemove"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
277
|
+
"onZr:contextmenu"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
278
|
+
"onZr:globalout"?: ((params: import("echarts").ElementEvent) => any) | undefined;
|
|
279
|
+
onHighlight?: ((...args: any[]) => any) | undefined;
|
|
280
|
+
onDownplay?: ((...args: any[]) => any) | undefined;
|
|
281
|
+
onSelectchanged?: ((...args: any[]) => any) | undefined;
|
|
282
|
+
onLegendselectchanged?: ((...args: any[]) => any) | undefined;
|
|
283
|
+
onLegendselected?: ((...args: any[]) => any) | undefined;
|
|
284
|
+
onLegendunselected?: ((...args: any[]) => any) | undefined;
|
|
285
|
+
onLegendselectall?: ((...args: any[]) => any) | undefined;
|
|
286
|
+
onLegendinverseselect?: ((...args: any[]) => any) | undefined;
|
|
287
|
+
onLegendscroll?: ((...args: any[]) => any) | undefined;
|
|
288
|
+
onDatazoom?: ((...args: any[]) => any) | undefined;
|
|
289
|
+
onDatarangeselected?: ((...args: any[]) => any) | undefined;
|
|
290
|
+
onGraphroam?: ((...args: any[]) => any) | undefined;
|
|
291
|
+
onGeoroam?: ((...args: any[]) => any) | undefined;
|
|
292
|
+
onTreeroam?: ((...args: any[]) => any) | undefined;
|
|
293
|
+
onTimelinechanged?: ((...args: any[]) => any) | undefined;
|
|
294
|
+
onTimelineplaychanged?: ((...args: any[]) => any) | undefined;
|
|
295
|
+
onRestore?: ((...args: any[]) => any) | undefined;
|
|
296
|
+
onDataviewchanged?: ((...args: any[]) => any) | undefined;
|
|
297
|
+
onMagictypechanged?: ((...args: any[]) => any) | undefined;
|
|
298
|
+
onGeoselectchanged?: ((...args: any[]) => any) | undefined;
|
|
299
|
+
onGeoselected?: ((...args: any[]) => any) | undefined;
|
|
300
|
+
onGeounselected?: ((...args: any[]) => any) | undefined;
|
|
301
|
+
onAxisareaselected?: ((...args: any[]) => any) | undefined;
|
|
302
|
+
onBrush?: ((...args: any[]) => any) | undefined;
|
|
303
|
+
onBrushEnd?: ((...args: any[]) => any) | undefined;
|
|
304
|
+
onBrushselected?: ((...args: any[]) => any) | undefined;
|
|
305
|
+
onGlobalcursortaken?: ((...args: any[]) => any) | undefined;
|
|
306
|
+
onRendered?: ((params: {
|
|
307
|
+
elapsedTime: number;
|
|
308
|
+
}) => any) | undefined;
|
|
309
|
+
onFinished?: (() => any) | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
manualUpdate: boolean;
|
|
312
|
+
loading: boolean;
|
|
313
|
+
}, {}>;
|
|
314
|
+
export default _default;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
shallowRef,
|
|
4
|
+
toRefs,
|
|
5
|
+
unref,
|
|
6
|
+
watch,
|
|
7
|
+
computed,
|
|
8
|
+
inject,
|
|
9
|
+
onMounted,
|
|
10
|
+
onBeforeUnmount,
|
|
11
|
+
h,
|
|
12
|
+
nextTick,
|
|
13
|
+
watchEffect
|
|
14
|
+
} from "vue";
|
|
15
|
+
import { init as initChart } from "echarts/core";
|
|
16
|
+
import {
|
|
17
|
+
usePublicAPI,
|
|
18
|
+
useAutoresize,
|
|
19
|
+
autoresizeProps,
|
|
20
|
+
useLoading,
|
|
21
|
+
loadingProps
|
|
22
|
+
} from "./composables/index.mjs";
|
|
23
|
+
import { isOn, omitOn } from "./utils.mjs";
|
|
24
|
+
import { register, TAG_NAME } from "./wc.mjs";
|
|
25
|
+
import "./style.css";
|
|
26
|
+
const wcRegistered = register();
|
|
27
|
+
export const THEME_KEY = "ecTheme";
|
|
28
|
+
export const INIT_OPTIONS_KEY = "ecInitOptions";
|
|
29
|
+
export const UPDATE_OPTIONS_KEY = "ecUpdateOptions";
|
|
30
|
+
export { LOADING_OPTIONS_KEY } from "./composables/index.mjs";
|
|
31
|
+
export default defineComponent({
|
|
32
|
+
name: "echarts",
|
|
33
|
+
props: {
|
|
34
|
+
option: Object,
|
|
35
|
+
theme: {
|
|
36
|
+
type: [Object, String]
|
|
37
|
+
},
|
|
38
|
+
initOptions: Object,
|
|
39
|
+
updateOptions: Object,
|
|
40
|
+
group: String,
|
|
41
|
+
manualUpdate: Boolean,
|
|
42
|
+
...autoresizeProps,
|
|
43
|
+
...loadingProps
|
|
44
|
+
},
|
|
45
|
+
emits: {},
|
|
46
|
+
inheritAttrs: false,
|
|
47
|
+
setup(props, { attrs }) {
|
|
48
|
+
const root = shallowRef();
|
|
49
|
+
const inner = shallowRef();
|
|
50
|
+
const chart = shallowRef();
|
|
51
|
+
const manualOption = shallowRef();
|
|
52
|
+
const defaultTheme = inject(THEME_KEY, null);
|
|
53
|
+
const defaultInitOptions = inject(INIT_OPTIONS_KEY, null);
|
|
54
|
+
const defaultUpdateOptions = inject(UPDATE_OPTIONS_KEY, null);
|
|
55
|
+
const { autoresize, manualUpdate, loading, loadingOptions } = toRefs(props);
|
|
56
|
+
const realOption = computed(
|
|
57
|
+
() => manualOption.value || props.option || null
|
|
58
|
+
);
|
|
59
|
+
const realTheme = computed(() => props.theme || unref(defaultTheme) || {});
|
|
60
|
+
const realInitOptions = computed(
|
|
61
|
+
// @ts-expect-error unknown computed type error
|
|
62
|
+
() => props.initOptions || unref(defaultInitOptions) || {}
|
|
63
|
+
);
|
|
64
|
+
const realUpdateOptions = computed(
|
|
65
|
+
// @ts-expect-error unknown computed type error
|
|
66
|
+
() => props.updateOptions || unref(defaultUpdateOptions) || {}
|
|
67
|
+
);
|
|
68
|
+
const nonEventAttrs = computed(() => omitOn(attrs));
|
|
69
|
+
const nativeListeners = {};
|
|
70
|
+
const realListeners = {};
|
|
71
|
+
Object.keys(attrs).filter((key) => isOn(key)).forEach((key) => {
|
|
72
|
+
let event = key.charAt(2).toLowerCase() + key.slice(3);
|
|
73
|
+
if (event.indexOf("native:") === 0) {
|
|
74
|
+
const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
|
|
75
|
+
8
|
|
76
|
+
)}`;
|
|
77
|
+
nativeListeners[nativeKey] = attrs[key];
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (event.substring(event.length - 4) === "Once") {
|
|
81
|
+
event = `~${event.substring(0, event.length - 4)}`;
|
|
82
|
+
}
|
|
83
|
+
realListeners[event] = attrs[key];
|
|
84
|
+
});
|
|
85
|
+
function init(option) {
|
|
86
|
+
if (!inner.value) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const instance = chart.value = initChart(
|
|
90
|
+
inner.value,
|
|
91
|
+
realTheme.value,
|
|
92
|
+
realInitOptions.value
|
|
93
|
+
);
|
|
94
|
+
if (props.group) {
|
|
95
|
+
instance.group = props.group;
|
|
96
|
+
}
|
|
97
|
+
Object.keys(realListeners).forEach((key) => {
|
|
98
|
+
let handler = realListeners[key];
|
|
99
|
+
if (!handler) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let event = key.toLowerCase();
|
|
103
|
+
if (event.charAt(0) === "~") {
|
|
104
|
+
event = event.substring(1);
|
|
105
|
+
handler.__once__ = true;
|
|
106
|
+
}
|
|
107
|
+
let target = instance;
|
|
108
|
+
if (event.indexOf("zr:") === 0) {
|
|
109
|
+
target = instance.getZr();
|
|
110
|
+
event = event.substring(3);
|
|
111
|
+
}
|
|
112
|
+
if (handler.__once__) {
|
|
113
|
+
delete handler.__once__;
|
|
114
|
+
const raw = handler;
|
|
115
|
+
handler = (...args) => {
|
|
116
|
+
raw(...args);
|
|
117
|
+
target.off(event, handler);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
target.on(event, handler);
|
|
121
|
+
});
|
|
122
|
+
function resize() {
|
|
123
|
+
if (instance && !instance.isDisposed()) {
|
|
124
|
+
instance.resize();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function commit() {
|
|
128
|
+
const opt = option || realOption.value;
|
|
129
|
+
if (opt) {
|
|
130
|
+
instance.setOption(opt, realUpdateOptions.value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (autoresize.value) {
|
|
134
|
+
nextTick(() => {
|
|
135
|
+
resize();
|
|
136
|
+
commit();
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
commit();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function setOption(option, updateOptions) {
|
|
143
|
+
if (props.manualUpdate) {
|
|
144
|
+
manualOption.value = option;
|
|
145
|
+
}
|
|
146
|
+
if (!chart.value) {
|
|
147
|
+
init(option);
|
|
148
|
+
} else {
|
|
149
|
+
chart.value.setOption(option, updateOptions || {});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function cleanup() {
|
|
153
|
+
if (chart.value) {
|
|
154
|
+
chart.value.dispose();
|
|
155
|
+
chart.value = void 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let unwatchOption = null;
|
|
159
|
+
watch(
|
|
160
|
+
manualUpdate,
|
|
161
|
+
(manualUpdate2) => {
|
|
162
|
+
if (typeof unwatchOption === "function") {
|
|
163
|
+
unwatchOption();
|
|
164
|
+
unwatchOption = null;
|
|
165
|
+
}
|
|
166
|
+
if (!manualUpdate2) {
|
|
167
|
+
unwatchOption = watch(
|
|
168
|
+
() => props.option,
|
|
169
|
+
(option, oldOption) => {
|
|
170
|
+
if (!option) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!chart.value) {
|
|
174
|
+
init();
|
|
175
|
+
} else {
|
|
176
|
+
chart.value.setOption(option, {
|
|
177
|
+
// mutating `option` will lead to `notMerge: false` and
|
|
178
|
+
// replacing it with new reference will lead to `notMerge: true`
|
|
179
|
+
notMerge: option !== oldOption,
|
|
180
|
+
...realUpdateOptions.value
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{ deep: true }
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
immediate: true
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
watch(
|
|
193
|
+
[realTheme, realInitOptions],
|
|
194
|
+
() => {
|
|
195
|
+
cleanup();
|
|
196
|
+
init();
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
deep: true
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
watchEffect(() => {
|
|
203
|
+
if (props.group && chart.value) {
|
|
204
|
+
chart.value.group = props.group;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const publicApi = usePublicAPI(chart);
|
|
208
|
+
useLoading(chart, loading, loadingOptions);
|
|
209
|
+
useAutoresize(chart, autoresize, inner);
|
|
210
|
+
onMounted(() => {
|
|
211
|
+
init();
|
|
212
|
+
});
|
|
213
|
+
onBeforeUnmount(() => {
|
|
214
|
+
if (wcRegistered && root.value) {
|
|
215
|
+
root.value.__dispose = cleanup;
|
|
216
|
+
} else {
|
|
217
|
+
cleanup();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
chart,
|
|
222
|
+
root,
|
|
223
|
+
inner,
|
|
224
|
+
setOption,
|
|
225
|
+
nonEventAttrs,
|
|
226
|
+
nativeListeners,
|
|
227
|
+
...publicApi
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
render() {
|
|
231
|
+
const attrs = { ...this.nonEventAttrs, ...this.nativeListeners };
|
|
232
|
+
attrs.ref = "root";
|
|
233
|
+
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
|
|
234
|
+
return h(TAG_NAME, attrs, [
|
|
235
|
+
h("div", { ref: "inner", class: "vue-echarts-inner" })
|
|
236
|
+
]);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { EChartsType } from '../types';
|
|
3
|
+
declare const METHOD_NAMES: readonly ["getWidth", "getHeight", "getDom", "getOption", "resize", "dispatchAction", "convertToPixel", "convertFromPixel", "containPixel", "getDataURL", "getConnectedDataURL", "appendData", "clear", "isDisposed", "dispose"];
|
|
4
|
+
type MethodName = (typeof METHOD_NAMES)[number];
|
|
5
|
+
type PublicMethods = Pick<EChartsType, MethodName>;
|
|
6
|
+
export declare function usePublicAPI(chart: Ref<EChartsType | undefined>): PublicMethods;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const METHOD_NAMES = [
|
|
2
|
+
"getWidth",
|
|
3
|
+
"getHeight",
|
|
4
|
+
"getDom",
|
|
5
|
+
"getOption",
|
|
6
|
+
"resize",
|
|
7
|
+
"dispatchAction",
|
|
8
|
+
"convertToPixel",
|
|
9
|
+
"convertFromPixel",
|
|
10
|
+
"containPixel",
|
|
11
|
+
"getDataURL",
|
|
12
|
+
"getConnectedDataURL",
|
|
13
|
+
"appendData",
|
|
14
|
+
"clear",
|
|
15
|
+
"isDisposed",
|
|
16
|
+
"dispose"
|
|
17
|
+
];
|
|
18
|
+
export function usePublicAPI(chart) {
|
|
19
|
+
function makePublicMethod(name) {
|
|
20
|
+
return (...args) => {
|
|
21
|
+
if (!chart.value) {
|
|
22
|
+
throw new Error("ECharts is not initialized yet.");
|
|
23
|
+
}
|
|
24
|
+
return chart.value[name].apply(chart.value, args);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function makePublicMethods() {
|
|
28
|
+
const methods = /* @__PURE__ */ Object.create(null);
|
|
29
|
+
METHOD_NAMES.forEach((name) => {
|
|
30
|
+
methods[name] = makePublicMethod(name);
|
|
31
|
+
});
|
|
32
|
+
return methods;
|
|
33
|
+
}
|
|
34
|
+
return makePublicMethods();
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Ref, type PropType } from 'vue';
|
|
2
|
+
import { type EChartsType } from '../types';
|
|
3
|
+
type AutoresizeProp = boolean | {
|
|
4
|
+
throttle?: number;
|
|
5
|
+
onResize?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function useAutoresize(chart: Ref<EChartsType | undefined>, autoresize: Ref<AutoresizeProp | undefined>, root: Ref<HTMLElement | undefined>): void;
|
|
8
|
+
export declare const autoresizeProps: {
|
|
9
|
+
autoresize: PropType<AutoresizeProp>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
import { throttle } from "echarts/core";
|
|
3
|
+
export function useAutoresize(chart, autoresize, root) {
|
|
4
|
+
let observer;
|
|
5
|
+
watch([root, chart, autoresize], ([root2, chart2, autoresize2], _, cleanup) => {
|
|
6
|
+
if (root2 && chart2 && autoresize2) {
|
|
7
|
+
const autoresizeOptions = autoresize2 === true ? {} : autoresize2;
|
|
8
|
+
const { throttle: wait = 100, onResize } = autoresizeOptions;
|
|
9
|
+
const callback = () => {
|
|
10
|
+
chart2.resize();
|
|
11
|
+
onResize?.();
|
|
12
|
+
};
|
|
13
|
+
observer = new ResizeObserver(wait ? throttle(callback, wait) : callback);
|
|
14
|
+
observer.observe(root2);
|
|
15
|
+
}
|
|
16
|
+
cleanup(() => {
|
|
17
|
+
if (root2 && observer) {
|
|
18
|
+
observer.disconnect();
|
|
19
|
+
observer = void 0;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export const autoresizeProps = {
|
|
25
|
+
autoresize: [Boolean, Object]
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Ref, type InjectionKey, type PropType } from 'vue';
|
|
2
|
+
import type { EChartsType, LoadingOptions } from '../types';
|
|
3
|
+
export declare const LOADING_OPTIONS_KEY: InjectionKey<LoadingOptions | Ref<LoadingOptions>>;
|
|
4
|
+
export declare function useLoading(chart: Ref<EChartsType | undefined>, loading: Ref<boolean>, loadingOptions: Ref<LoadingOptions | undefined>): void;
|
|
5
|
+
export declare const loadingProps: {
|
|
6
|
+
loading: BooleanConstructor;
|
|
7
|
+
loadingOptions: PropType<LoadingOptions>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
unref,
|
|
3
|
+
inject,
|
|
4
|
+
computed,
|
|
5
|
+
watchEffect
|
|
6
|
+
} from "vue";
|
|
7
|
+
export const LOADING_OPTIONS_KEY = "ecLoadingOptions";
|
|
8
|
+
export function useLoading(chart, loading, loadingOptions) {
|
|
9
|
+
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {});
|
|
10
|
+
const realLoadingOptions = computed(() => ({
|
|
11
|
+
...unref(defaultLoadingOptions) || {},
|
|
12
|
+
...loadingOptions?.value
|
|
13
|
+
}));
|
|
14
|
+
watchEffect(() => {
|
|
15
|
+
const instance = chart.value;
|
|
16
|
+
if (!instance) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (loading.value) {
|
|
20
|
+
instance.showLoading(realLoadingOptions.value);
|
|
21
|
+
} else {
|
|
22
|
+
instance.hideLoading();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export const loadingProps = {
|
|
27
|
+
loading: Boolean,
|
|
28
|
+
loadingOptions: Object
|
|
29
|
+
};
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
x-vue-echarts{display:block;height:100%;min-width:0;position:relative;width:100%}.vue-echarts-inner{bottom:0;left:0;position:absolute;right:0;top:0}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { init } from 'echarts/core';
|
|
2
|
+
import type { SetOptionOpts, ECElementEvent, ElementEvent } from 'echarts';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
4
|
+
export type Injection<T> = T | null | Ref<T | null> | {
|
|
5
|
+
value: T | null;
|
|
6
|
+
};
|
|
7
|
+
type InitType = typeof init;
|
|
8
|
+
export type InitParameters = Parameters<InitType>;
|
|
9
|
+
export type Theme = NonNullable<InitParameters[1]>;
|
|
10
|
+
export type ThemeInjection = Injection<Theme>;
|
|
11
|
+
export type InitOptions = NonNullable<InitParameters[2]>;
|
|
12
|
+
export type InitOptionsInjection = Injection<InitOptions>;
|
|
13
|
+
export type UpdateOptions = SetOptionOpts;
|
|
14
|
+
export type UpdateOptionsInjection = Injection<UpdateOptions>;
|
|
15
|
+
export type EChartsType = ReturnType<InitType>;
|
|
16
|
+
type ZRenderType = ReturnType<EChartsType['getZr']>;
|
|
17
|
+
export type EventTarget = EChartsType | ZRenderType;
|
|
18
|
+
type SetOptionType = EChartsType['setOption'];
|
|
19
|
+
export type Option = Parameters<SetOptionType>[0];
|
|
20
|
+
export type LoadingOptions = {
|
|
21
|
+
text?: string;
|
|
22
|
+
textColor?: string;
|
|
23
|
+
fontSize?: number | string;
|
|
24
|
+
fontWeight?: number | string;
|
|
25
|
+
fontStyle?: string;
|
|
26
|
+
fontFamily?: string;
|
|
27
|
+
maskColor?: string;
|
|
28
|
+
showSpinner?: boolean;
|
|
29
|
+
color?: string;
|
|
30
|
+
spinnerRadius?: number;
|
|
31
|
+
lineWidth?: number;
|
|
32
|
+
zlevel?: number;
|
|
33
|
+
};
|
|
34
|
+
type MouseEventName = 'click' | 'dblclick' | 'mouseout' | 'mouseover' | 'mouseup' | 'mousedown' | 'mousemove' | 'contextmenu' | 'globalout';
|
|
35
|
+
type ElementEventName = MouseEventName | 'mousewheel' | 'drag' | 'dragstart' | 'dragend' | 'dragenter' | 'dragleave' | 'dragover' | 'drop';
|
|
36
|
+
type ZRenderEventName = `zr:${ElementEventName}`;
|
|
37
|
+
type OtherEventName = 'highlight' | 'downplay' | 'selectchanged' | 'legendselectchanged' | 'legendselected' | 'legendunselected' | 'legendselectall' | 'legendinverseselect' | 'legendscroll' | 'datazoom' | 'datarangeselected' | 'graphroam' | 'georoam' | 'treeroam' | 'timelinechanged' | 'timelineplaychanged' | 'restore' | 'dataviewchanged' | 'magictypechanged' | 'geoselectchanged' | 'geoselected' | 'geounselected' | 'axisareaselected' | 'brush' | 'brushEnd' | 'brushselected' | 'globalcursortaken';
|
|
38
|
+
type MouseEmits = {
|
|
39
|
+
[key in MouseEventName]: (params: ECElementEvent) => boolean;
|
|
40
|
+
};
|
|
41
|
+
type ZRenderEmits = {
|
|
42
|
+
[key in ZRenderEventName]: (params: ElementEvent) => boolean;
|
|
43
|
+
};
|
|
44
|
+
type OtherEmits = {
|
|
45
|
+
[key in OtherEventName]: null;
|
|
46
|
+
};
|
|
47
|
+
export type Emits = MouseEmits & OtherEmits & {
|
|
48
|
+
rendered: (params: {
|
|
49
|
+
elapsedTime: number;
|
|
50
|
+
}) => boolean;
|
|
51
|
+
finished: () => boolean;
|
|
52
|
+
} & ZRenderEmits;
|
|
53
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
let registered = null;
|
|
2
|
+
export const TAG_NAME = "x-vue-echarts";
|
|
3
|
+
if (import.meta.server) {
|
|
4
|
+
global.HTMLElement = Object;
|
|
5
|
+
}
|
|
6
|
+
export class EChartsElement extends HTMLElement {
|
|
7
|
+
__dispose = null;
|
|
8
|
+
disconnectedCallback() {
|
|
9
|
+
if (this.__dispose) {
|
|
10
|
+
this.__dispose();
|
|
11
|
+
this.__dispose = null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function register() {
|
|
16
|
+
if (registered != null) {
|
|
17
|
+
return registered;
|
|
18
|
+
}
|
|
19
|
+
if (typeof HTMLElement === "undefined" || typeof customElements === "undefined") {
|
|
20
|
+
return registered = false;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
if (customElements.get(TAG_NAME) == null) {
|
|
24
|
+
customElements.define(TAG_NAME, EChartsElement);
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return registered = false;
|
|
28
|
+
}
|
|
29
|
+
return registered = true;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-echarts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Nuxt Module for Apache ECharts™",
|
|
5
5
|
"author": "Yue JIN <yuejin13@fudan.edu.cn>",
|
|
6
6
|
"repository": "kingyue737/nuxt-echarts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"packageManager": "pnpm@9.1.
|
|
9
|
+
"packageManager": "pnpm@9.1.4",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/types.d.ts",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nuxt/kit": "^3.11.2"
|
|
35
|
+
"@nuxt/kit": "^3.11.2",
|
|
36
|
+
"echarts": "^5.5.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@nuxt/devtools": "^1.3.2",
|