nuxt-echarts 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/README.md CHANGED
@@ -70,14 +70,12 @@ That's it! You can now use Nuxt ECharts in your Nuxt app ✨
70
70
 
71
71
  ## Credits
72
72
 
73
- The Nuxt ECharts module is heavily inspired by [vue-echarts](https://github.com/ecomfe/vue-echarts), created by [@Justineo](https://github.com/Justineo).
73
+ The Nuxt ECharts module depends on [vue-echarts](https://github.com/ecomfe/vue-echarts), created by [@Justineo](https://github.com/Justineo).
74
74
 
75
75
  ## License
76
76
 
77
77
  This project is licensed under the [MIT License](./LICENSE).
78
78
 
79
- This project also partially contains code derived or copied from [vue-echarts(MIT)](https://github.com/ecomfe/vue-echarts/blob/main/LICENSE).
80
-
81
79
  ## Notice
82
80
 
83
81
  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/).
package/dist/module.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.2.0"
6
6
  },
7
- "version": "0.4.0",
7
+ "version": "1.0.0",
8
8
  "builder": {
9
- "@nuxt/module-builder": "1.0.1",
10
- "unbuild": "3.5.0"
9
+ "@nuxt/module-builder": "1.0.2",
10
+ "unbuild": "3.6.0"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -135,9 +135,7 @@ const module = defineNuxtModule({
135
135
  "INIT_OPTIONS_KEY",
136
136
  "UPDATE_OPTIONS_KEY",
137
137
  "LOADING_OPTIONS_KEY"
138
- ].forEach(
139
- (name) => addImports({ name, from: resolve("./runtime/utils/injection") })
140
- );
138
+ ].forEach((name) => addImports({ name, from: "vue-echarts" }));
141
139
  }
142
140
  });
143
141
 
@@ -1,166 +1,5 @@
1
- import type { PropType } from 'vue';
2
- import type { Option, Theme, InitOptions, UpdateOptions } from '../types.js';
3
- import type { PublicMethods } from '../composables/index.js';
4
- import type { EChartsElement } from '../utils/wc.js';
1
+ import VChart from 'vue-echarts';
5
2
  import '#build/echarts.mjs';
6
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
- loading: BooleanConstructor;
8
- loadingOptions: PropType<import("../types.js").LoadingOptions>;
9
- autoresize: PropType<boolean | {
10
- throttle?: number;
11
- onResize?: ResizeObserverCallback;
12
- }>;
13
- option: PropType<Option>;
14
- theme: {
15
- type: PropType<Theme>;
16
- };
17
- initOptions: PropType<InitOptions>;
18
- updateOptions: PropType<UpdateOptions>;
19
- group: StringConstructor;
20
- manualUpdate: BooleanConstructor;
21
- }>, {
22
- setOption: {
23
- <Opt extends import("echarts/core").EChartsCoreOption>(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void;
24
- <Opt extends import("echarts/core").EChartsCoreOption>(option: Opt, opts?: import("echarts/core").SetOptionOpts): void;
25
- };
26
- root: import("vue").ShallowRef<EChartsElement | undefined, EChartsElement | undefined>;
27
- chart: import("vue").ShallowRef<import("echarts/core").ECharts | undefined, import("echarts/core").ECharts | undefined>;
28
- } & PublicMethods, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
29
- click: (params: import("echarts/core").ECElementEvent) => void;
30
- dblclick: (params: import("echarts/core").ECElementEvent) => void;
31
- mouseout: (params: import("echarts/core").ECElementEvent) => void;
32
- mouseover: (params: import("echarts/core").ECElementEvent) => void;
33
- mouseup: (params: import("echarts/core").ECElementEvent) => void;
34
- mousedown: (params: import("echarts/core").ECElementEvent) => void;
35
- mousemove: (params: import("echarts/core").ECElementEvent) => void;
36
- contextmenu: (params: import("echarts/core").ECElementEvent) => void;
37
- globalout: (params: import("echarts/core").ECElementEvent) => void;
38
- } & {
39
- highlight: (params: any) => void;
40
- downplay: (params: any) => void;
41
- selectchanged: (params: any) => void;
42
- legendselectchanged: (params: any) => void;
43
- legendselected: (params: any) => void;
44
- legendunselected: (params: any) => void;
45
- legendselectall: (params: any) => void;
46
- legendinverseselect: (params: any) => void;
47
- legendscroll: (params: any) => void;
48
- datazoom: (params: any) => void;
49
- datarangeselected: (params: any) => void;
50
- graphroam: (params: any) => void;
51
- georoam: (params: any) => void;
52
- treeroam: (params: any) => void;
53
- timelinechanged: (params: any) => void;
54
- timelineplaychanged: (params: any) => void;
55
- restore: (params: any) => void;
56
- dataviewchanged: (params: any) => void;
57
- magictypechanged: (params: any) => void;
58
- geoselectchanged: (params: any) => void;
59
- geoselected: (params: any) => void;
60
- geounselected: (params: any) => void;
61
- axisareaselected: (params: any) => void;
62
- brush: (params: any) => void;
63
- brushEnd: (params: any) => void;
64
- brushselected: (params: any) => void;
65
- globalcursortaken: (params: any) => void;
66
- } & {
67
- rendered: (params: {
68
- elapsedTime: number;
69
- }) => void;
70
- finished: () => void;
71
- } & {
72
- "zr:mousewheel": (params: import("echarts/core").ElementEvent) => void;
73
- "zr:drag": (params: import("echarts/core").ElementEvent) => void;
74
- "zr:dragstart": (params: import("echarts/core").ElementEvent) => void;
75
- "zr:dragend": (params: import("echarts/core").ElementEvent) => void;
76
- "zr:dragenter": (params: import("echarts/core").ElementEvent) => void;
77
- "zr:dragleave": (params: import("echarts/core").ElementEvent) => void;
78
- "zr:dragover": (params: import("echarts/core").ElementEvent) => void;
79
- "zr:drop": (params: import("echarts/core").ElementEvent) => void;
80
- "zr:click": (params: import("echarts/core").ElementEvent) => void;
81
- "zr:dblclick": (params: import("echarts/core").ElementEvent) => void;
82
- "zr:mouseout": (params: import("echarts/core").ElementEvent) => void;
83
- "zr:mouseover": (params: import("echarts/core").ElementEvent) => void;
84
- "zr:mouseup": (params: import("echarts/core").ElementEvent) => void;
85
- "zr:mousedown": (params: import("echarts/core").ElementEvent) => void;
86
- "zr:mousemove": (params: import("echarts/core").ElementEvent) => void;
87
- "zr:contextmenu": (params: import("echarts/core").ElementEvent) => void;
88
- "zr:globalout": (params: import("echarts/core").ElementEvent) => void;
89
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
90
- loading: BooleanConstructor;
91
- loadingOptions: PropType<import("../types.js").LoadingOptions>;
92
- autoresize: PropType<boolean | {
93
- throttle?: number;
94
- onResize?: ResizeObserverCallback;
95
- }>;
96
- option: PropType<Option>;
97
- theme: {
98
- type: PropType<Theme>;
99
- };
100
- initOptions: PropType<InitOptions>;
101
- updateOptions: PropType<UpdateOptions>;
102
- group: StringConstructor;
103
- manualUpdate: BooleanConstructor;
104
- }>> & Readonly<{
105
- onClick?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
106
- onDblclick?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
107
- onMouseout?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
108
- onMouseover?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
109
- onMouseup?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
110
- onMousedown?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
111
- onMousemove?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
112
- onContextmenu?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
113
- onGlobalout?: ((params: import("echarts/core").ECElementEvent) => any) | undefined;
114
- "onZr:mousewheel"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
115
- "onZr:drag"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
116
- "onZr:dragstart"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
117
- "onZr:dragend"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
118
- "onZr:dragenter"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
119
- "onZr:dragleave"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
120
- "onZr:dragover"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
121
- "onZr:drop"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
122
- "onZr:click"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
123
- "onZr:dblclick"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
124
- "onZr:mouseout"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
125
- "onZr:mouseover"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
126
- "onZr:mouseup"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
127
- "onZr:mousedown"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
128
- "onZr:mousemove"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
129
- "onZr:contextmenu"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
130
- "onZr:globalout"?: ((params: import("echarts/core").ElementEvent) => any) | undefined;
131
- onHighlight?: ((params: any) => any) | undefined;
132
- onDownplay?: ((params: any) => any) | undefined;
133
- onSelectchanged?: ((params: any) => any) | undefined;
134
- onLegendselectchanged?: ((params: any) => any) | undefined;
135
- onLegendselected?: ((params: any) => any) | undefined;
136
- onLegendunselected?: ((params: any) => any) | undefined;
137
- onLegendselectall?: ((params: any) => any) | undefined;
138
- onLegendinverseselect?: ((params: any) => any) | undefined;
139
- onLegendscroll?: ((params: any) => any) | undefined;
140
- onDatazoom?: ((params: any) => any) | undefined;
141
- onDatarangeselected?: ((params: any) => any) | undefined;
142
- onGraphroam?: ((params: any) => any) | undefined;
143
- onGeoroam?: ((params: any) => any) | undefined;
144
- onTreeroam?: ((params: any) => any) | undefined;
145
- onTimelinechanged?: ((params: any) => any) | undefined;
146
- onTimelineplaychanged?: ((params: any) => any) | undefined;
147
- onRestore?: ((params: any) => any) | undefined;
148
- onDataviewchanged?: ((params: any) => any) | undefined;
149
- onMagictypechanged?: ((params: any) => any) | undefined;
150
- onGeoselectchanged?: ((params: any) => any) | undefined;
151
- onGeoselected?: ((params: any) => any) | undefined;
152
- onGeounselected?: ((params: any) => any) | undefined;
153
- onAxisareaselected?: ((params: any) => any) | undefined;
154
- onBrush?: ((params: any) => any) | undefined;
155
- onBrushEnd?: ((params: any) => any) | undefined;
156
- onBrushselected?: ((params: any) => any) | undefined;
157
- onGlobalcursortaken?: ((params: any) => any) | undefined;
158
- onRendered?: ((params: {
159
- elapsedTime: number;
160
- }) => any) | undefined;
161
- onFinished?: (() => any) | undefined;
162
- }>, {
163
- manualUpdate: boolean;
164
- loading: boolean;
165
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
+ type VChartType = typeof VChart;
4
+ declare const _default: VChartType;
166
5
  export default _default;
@@ -1,225 +1,39 @@
1
- import {
2
- defineComponent,
3
- shallowRef,
4
- toRefs,
5
- toValue,
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.js";
23
- import { isOn, omitOn } from "../utils/on.js";
24
- import { register, TAG_NAME } from "../utils/wc.js";
1
+ import VChart from "vue-echarts";
25
2
  import "#build/echarts.mjs";
26
- import {
27
- THEME_KEY,
28
- INIT_OPTIONS_KEY,
29
- UPDATE_OPTIONS_KEY
30
- } from "../utils/injection.js";
31
- const wcRegistered = register();
3
+ import { defineComponent, h, ref, toRef } from "vue";
4
+ const METHOD_NAMES = [
5
+ "setOption",
6
+ "getWidth",
7
+ "getHeight",
8
+ "getDom",
9
+ "getOption",
10
+ "resize",
11
+ "dispatchAction",
12
+ "convertToPixel",
13
+ "convertFromPixel",
14
+ "containPixel",
15
+ "getDataURL",
16
+ "getConnectedDataURL",
17
+ "appendData",
18
+ "clear",
19
+ "isDisposed",
20
+ "dispose"
21
+ ];
32
22
  export default defineComponent({
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
23
  inheritAttrs: false,
47
- setup(props, { attrs, expose }) {
48
- const root = shallowRef();
49
- const chart = shallowRef();
50
- const manualOption = shallowRef();
51
- const defaultTheme = inject(THEME_KEY, null);
52
- const defaultInitOptions = inject(INIT_OPTIONS_KEY, null);
53
- const defaultUpdateOptions = inject(UPDATE_OPTIONS_KEY, null);
54
- const { autoresize, manualUpdate, loading, loadingOptions } = toRefs(props);
55
- const realOption = computed(
56
- () => manualOption.value || props.option || null
24
+ setup(props, { attrs, slots, expose }) {
25
+ const root = ref(null);
26
+ const publicMethods = Object.fromEntries(
27
+ METHOD_NAMES.map((name) => [
28
+ name,
29
+ (...args) => (root.value?.[name])(...args)
30
+ ])
57
31
  );
58
- const realTheme = computed(() => props.theme || toValue(defaultTheme) || {});
59
- const realInitOptions = computed(
60
- () => props.initOptions || toValue(defaultInitOptions) || {}
61
- );
62
- const realUpdateOptions = computed(
63
- () => props.updateOptions || toValue(defaultUpdateOptions) || {}
64
- );
65
- const nonEventAttrs = computed(() => omitOn(attrs));
66
- const nativeListeners = {};
67
- const listeners = /* @__PURE__ */ new Map();
68
- Object.keys(attrs).filter((key) => isOn(key)).forEach((key) => {
69
- if (key.indexOf("Native:") === 2) {
70
- const nativeKey = `on${key.charAt(9).toUpperCase()}${key.slice(10)}`;
71
- nativeListeners[nativeKey] = attrs[key];
72
- return;
73
- }
74
- let event = key.charAt(2).toLowerCase() + key.slice(3);
75
- let zr;
76
- if (event.indexOf("zr:") === 0) {
77
- zr = true;
78
- event = event.substring(3);
79
- }
80
- let once;
81
- if (event.substring(event.length - 4) === "Once") {
82
- once = true;
83
- event = event.substring(0, event.length - 4);
84
- }
85
- listeners.set({ event, zr, once }, attrs[key]);
86
- });
87
- function init(option) {
88
- if (!root.value) {
89
- return;
90
- }
91
- const instance = chart.value = initChart(
92
- root.value,
93
- realTheme.value,
94
- realInitOptions.value
95
- );
96
- if (props.group) {
97
- instance.group = props.group;
98
- }
99
- listeners.forEach((handler, { zr, once, event }) => {
100
- if (!handler) {
101
- return;
102
- }
103
- const target = zr ? instance.getZr() : instance;
104
- if (once) {
105
- const raw = handler;
106
- handler = (...args) => {
107
- raw(...args);
108
- target.off(event, handler);
109
- };
110
- }
111
- target.on(event, handler);
112
- });
113
- function resize() {
114
- if (instance && !instance.isDisposed()) {
115
- instance.resize();
116
- }
117
- }
118
- function commit() {
119
- const opt = option || realOption.value;
120
- if (opt) {
121
- instance.setOption(opt, realUpdateOptions.value);
122
- }
123
- }
124
- if (autoresize.value) {
125
- nextTick(() => {
126
- resize();
127
- commit();
128
- });
129
- } else {
130
- commit();
131
- }
132
- }
133
- const setOption = (option, notMerge, lazyUpdate) => {
134
- const updateOptions = typeof notMerge === "boolean" ? { notMerge, lazyUpdate } : notMerge;
135
- if (props.manualUpdate) {
136
- manualOption.value = option;
137
- }
138
- if (!chart.value) {
139
- init(option);
140
- } else {
141
- chart.value.setOption(option, updateOptions || {});
142
- }
143
- };
144
- function cleanup() {
145
- if (chart.value) {
146
- chart.value.dispose();
147
- chart.value = void 0;
148
- }
149
- }
150
- let unwatchOption = null;
151
- watch(
152
- manualUpdate,
153
- (manualUpdate2) => {
154
- if (typeof unwatchOption === "function") {
155
- unwatchOption();
156
- unwatchOption = null;
157
- }
158
- if (!manualUpdate2) {
159
- unwatchOption = watch(
160
- () => props.option,
161
- (option, oldOption) => {
162
- if (!option) {
163
- return;
164
- }
165
- if (!chart.value) {
166
- init();
167
- } else {
168
- chart.value.setOption(option, {
169
- // mutating `option` will lead to `notMerge: false` and
170
- // replacing it with new reference will lead to `notMerge: true`
171
- notMerge: option !== oldOption,
172
- ...realUpdateOptions.value
173
- });
174
- }
175
- },
176
- { deep: true }
177
- );
178
- }
179
- },
180
- {
181
- immediate: true
182
- }
183
- );
184
- watch(
185
- [realTheme, realInitOptions],
186
- () => {
187
- cleanup();
188
- init();
189
- },
190
- {
191
- deep: true
192
- }
193
- );
194
- watchEffect(() => {
195
- if (props.group && chart.value) {
196
- chart.value.group = props.group;
197
- }
198
- });
199
- const publicApi = usePublicAPI(chart);
200
- useLoading(chart, loading, loadingOptions);
201
- useAutoresize(chart, autoresize, root);
202
- onMounted(() => {
203
- init();
204
- });
205
- onBeforeUnmount(() => {
206
- if (wcRegistered && root.value) {
207
- root.value.__dispose = cleanup;
208
- } else {
209
- cleanup();
210
- }
211
- });
212
- const exposed = {
213
- setOption,
214
- root,
215
- chart
216
- };
217
- expose({ ...exposed, ...publicApi });
218
- return () => h(TAG_NAME, {
219
- ...nonEventAttrs.value,
220
- ...nativeListeners,
221
- ref: root,
222
- class: ["echarts", nonEventAttrs.value.class]
32
+ expose({
33
+ ...publicMethods,
34
+ root: toRef(() => root.value?.root),
35
+ chart: toRef(() => root.value?.chart)
223
36
  });
37
+ return () => h(VChart, { ...attrs, ref: root }, slots);
224
38
  }
225
39
  });
@@ -19,8 +19,8 @@ defineSlots();
19
19
  </script>
20
20
 
21
21
  <template>
22
- <div class="vue-echarts-container">
23
- <!--eslint-disable-next-line vue/no-v-html-->
24
- <div class="vue-echarts-inner" v-html="svgStr" />
25
- </div>
22
+ <div class="vue-echarts-container">
23
+ <!--eslint-disable-next-line vue/no-v-html-->
24
+ <div class="vue-echarts-inner" v-html="svgStr" />
25
+ </div>
26
26
  </template>
@@ -54,10 +54,10 @@ export default defineComponent({
54
54
  </script>
55
55
 
56
56
  <template>
57
- <VChartServer
58
- ref="root"
59
- :option="option"
60
- :init-options="initOptions"
61
- :theme="theme"
62
- />
57
+ <VChartServer
58
+ ref="root"
59
+ :option="option"
60
+ :init-options="initOptions"
61
+ :theme="theme"
62
+ />
63
63
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, inject, ref, toValue } from "vue";
3
- import { THEME_KEY, INIT_OPTIONS_KEY } from "../utils/injection";
3
+ import { THEME_KEY, INIT_OPTIONS_KEY } from "vue-echarts";
4
4
  const defaultTheme = inject(THEME_KEY, null);
5
5
  const defaultInitOptions = inject(INIT_OPTIONS_KEY, null);
6
6
  const props = defineProps({
@@ -1,2 +1,2 @@
1
- declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,49 +1,9 @@
1
- import type { init, SetOptionOpts, ECElementEvent, ElementEvent } from 'echarts/core';
2
- import type { MaybeRefOrGetter } from 'vue';
3
- export type Injection<T> = MaybeRefOrGetter<T | null>;
1
+ import type { init } from 'echarts/core';
4
2
  type InitType = typeof init;
5
3
  export type InitParameters = Parameters<InitType>;
6
4
  export type Theme = NonNullable<InitParameters[1]>;
7
- export type ThemeInjection = Injection<Theme>;
8
5
  export type InitOptions = NonNullable<InitParameters[2]>;
9
- export type InitOptionsInjection = Injection<InitOptions>;
10
- export type UpdateOptions = SetOptionOpts;
11
- export type UpdateOptionsInjection = Injection<UpdateOptions>;
12
- export type EChartsType = ReturnType<InitType>;
13
- export type SetOptionType = EChartsType['setOption'];
6
+ type EChartsType = ReturnType<InitType>;
7
+ type SetOptionType = EChartsType['setOption'];
14
8
  export type Option = Parameters<SetOptionType>[0];
15
- export type LoadingOptions = {
16
- text?: string;
17
- textColor?: string;
18
- fontSize?: number | string;
19
- fontWeight?: number | string;
20
- fontStyle?: string;
21
- fontFamily?: string;
22
- maskColor?: string;
23
- showSpinner?: boolean;
24
- color?: string;
25
- spinnerRadius?: number;
26
- lineWidth?: number;
27
- zlevel?: number;
28
- };
29
- export type LoadingOptionsInjection = Injection<LoadingOptions>;
30
- type MouseEventName = 'click' | 'dblclick' | 'mouseout' | 'mouseover' | 'mouseup' | 'mousedown' | 'mousemove' | 'contextmenu' | 'globalout';
31
- type ElementEventName = MouseEventName | 'mousewheel' | 'drag' | 'dragstart' | 'dragend' | 'dragenter' | 'dragleave' | 'dragover' | 'drop';
32
- type ZRenderEventName = `zr:${ElementEventName}`;
33
- 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';
34
- type MouseEmits = {
35
- [key in MouseEventName]: (params: ECElementEvent) => void;
36
- };
37
- type ZRenderEmits = {
38
- [key in ZRenderEventName]: (params: ElementEvent) => void;
39
- };
40
- type OtherEmits = {
41
- [key in OtherEventName]: (params: any) => void;
42
- };
43
- export type Emits = MouseEmits & OtherEmits & {
44
- rendered: (params: {
45
- elapsedTime: number;
46
- }) => void;
47
- finished: () => void;
48
- } & ZRenderEmits;
49
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-echarts",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "description": "Nuxt Module for Apache ECharts™",
5
5
  "keywords": [
6
6
  "vue",
@@ -14,7 +14,6 @@
14
14
  "repository": "kingyue737/nuxt-echarts",
15
15
  "license": "MIT",
16
16
  "type": "module",
17
- "packageManager": "pnpm@10.13.1",
18
17
  "exports": {
19
18
  ".": {
20
19
  "types": "./dist/types.d.mts",
@@ -26,49 +25,50 @@
26
25
  "files": [
27
26
  "dist"
28
27
  ],
29
- "scripts": {
30
- "prepack": "nuxt-module-build build",
31
- "dev": "nuxi dev playground",
32
- "dev:build": "pnpm run dev:prepare && nuxi build playground",
33
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
34
- "release": "pnpm run lint && pnpm run test && pnpm run prepack && changelogen --release && npm publish --registry=\"https://registry.npmjs.org/\" && git push --follow-tags",
35
- "release:nightly": "pnpm changelogen --canary --publish --publishTag nightly",
36
- "docs:dev": "nuxi dev docs",
37
- "docs:build": "nuxi build docs",
38
- "docs:types": "nuxi typecheck docs",
39
- "lint": "eslint . --fix",
40
- "format": "prettier . --write",
41
- "test": "vitest run",
42
- "test:watch": "vitest watch",
43
- "test:types": "vue-tsc --noEmit && nuxi typecheck playground"
44
- },
45
28
  "dependencies": {
46
- "@nuxt/kit": "^4.0.0"
29
+ "@nuxt/kit": "^4.0.3"
47
30
  },
48
31
  "devDependencies": {
49
- "@nuxt/eslint-config": "^1.6.0",
50
- "@nuxt/module-builder": "^1.0.1",
51
- "@nuxt/schema": "^4.0.0",
32
+ "@nuxt/eslint-config": "^1.8.0",
33
+ "@nuxt/module-builder": "^1.0.2",
34
+ "@nuxt/schema": "^4.0.3",
52
35
  "@nuxt/test-utils": "^3.19.2",
53
36
  "@nuxthub/core": "^0.9.0",
54
- "@types/node": "^22.16.5",
37
+ "@types/node": "^22.17.1",
55
38
  "changelogen": "^0.6.2",
56
- "echarts": "^5.6.0",
39
+ "echarts": "^6.0.0",
57
40
  "embla-carousel": "^8.6.0",
58
- "eslint": "^9.31.0",
59
- "nuxt": "^4.0.0",
41
+ "eslint": "^9.33.0",
42
+ "nuxt": "^4.0.3",
60
43
  "prettier": "^3.6.2",
61
44
  "prettier-plugin-tailwindcss": "^0.6.14",
62
- "typescript": "^5.8.3",
63
- "vite": "^7.0.5",
45
+ "typescript": "^5.9.2",
46
+ "vite": "^7.1.1",
64
47
  "vitest": "^3.2.4",
65
- "vue-tsc": "^3.0.3",
66
- "wrangler": "^4.25.0"
48
+ "vue-echarts": "^8.0.0-beta.1",
49
+ "vue-tsc": "^3.0.5",
50
+ "wrangler": "^4.28.1"
67
51
  },
68
52
  "peerDependencies": {
69
- "echarts": "^5.5.1"
53
+ "echarts": "^6.0.0",
54
+ "vue-echarts": "^8.0.0-beta.1"
70
55
  },
71
56
  "stackblitz": {
72
57
  "startCommand": "pnpm run dev:prepare && pnpm run dev"
58
+ },
59
+ "scripts": {
60
+ "dev": "nuxi dev playground",
61
+ "dev:build": "nuxi build playground",
62
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
63
+ "release": "pnpm run lint && pnpm run test && pnpm run prepack && changelogen --release && npm publish --registry=\"https://registry.npmjs.org/\" && git push --follow-tags",
64
+ "release:nightly": "pnpm changelogen --canary --publish --publishTag nightly",
65
+ "docs:dev": "nuxi dev docs",
66
+ "docs:build": "nuxi build docs",
67
+ "docs:types": "nuxi typecheck docs",
68
+ "lint": "eslint . --fix",
69
+ "format": "prettier . --write",
70
+ "test": "vitest run",
71
+ "test:watch": "vitest watch",
72
+ "test:types": "vue-tsc --noEmit && nuxi typecheck playground"
73
73
  }
74
- }
74
+ }
@@ -1,7 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { EChartsType } from '../types.js';
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
- export type PublicMethods = Pick<EChartsType, MethodName>;
6
- export declare function usePublicAPI(chart: Ref<EChartsType | undefined>): PublicMethods;
7
- export {};
@@ -1,35 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
1
- import { type Ref, type PropType } from 'vue';
2
- import type { EChartsType } from '../types.js';
3
- type AutoresizeProp = boolean | {
4
- throttle?: number;
5
- onResize?: ResizeObserverCallback;
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 {};
@@ -1,46 +0,0 @@
1
- import { watch } from "vue";
2
- import { throttle } from "echarts/core";
3
- export function useAutoresize(chart, autoresize, root) {
4
- watch(
5
- [root, chart, autoresize],
6
- ([root2, chart2, autoresize2], _, onCleanup) => {
7
- let ro = null;
8
- if (root2 && chart2 && autoresize2) {
9
- const { offsetWidth, offsetHeight } = root2;
10
- const autoresizeOptions = autoresize2 === true ? {} : autoresize2;
11
- const { throttle: wait = 100, onResize } = autoresizeOptions;
12
- let initialResizeTriggered = false;
13
- const callback = (entry, ob) => {
14
- chart2.resize({ height: "auto", width: "auto" });
15
- onResize?.(entry, ob);
16
- };
17
- const resizeCallback = wait ? (
18
- // @ts-expect-error callback can accept params
19
- throttle(callback, wait)
20
- ) : callback;
21
- ro = new ResizeObserver((entry, observer) => {
22
- if (!initialResizeTriggered) {
23
- initialResizeTriggered = true;
24
- if (root2.offsetWidth === offsetWidth && root2.offsetHeight === offsetHeight) {
25
- return;
26
- }
27
- }
28
- if (root2.offsetWidth === 0 || root2.offsetHeight === 0) {
29
- return;
30
- }
31
- resizeCallback(entry, observer);
32
- });
33
- ro.observe(root2);
34
- }
35
- onCleanup(() => {
36
- if (ro) {
37
- ro.disconnect();
38
- ro = null;
39
- }
40
- });
41
- }
42
- );
43
- }
44
- export const autoresizeProps = {
45
- autoresize: [Boolean, Object]
46
- };
@@ -1,3 +0,0 @@
1
- export * from './api.js';
2
- export * from './autoresize.js';
3
- export * from './loading.js';
@@ -1,3 +0,0 @@
1
- export * from "./api.js";
2
- export * from "./autoresize.js";
3
- export * from "./loading.js";
@@ -1,8 +0,0 @@
1
- import { type Ref, type InjectionKey, type PropType } from 'vue';
2
- import type { EChartsType, LoadingOptions, LoadingOptionsInjection } from '../types.js';
3
- export declare const LOADING_OPTIONS_KEY: InjectionKey<LoadingOptionsInjection>;
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
- };
@@ -1,29 +0,0 @@
1
- import {
2
- toValue,
3
- inject,
4
- computed,
5
- watchEffect
6
- } from "vue";
7
- export const LOADING_OPTIONS_KEY = Symbol();
8
- export function useLoading(chart, loading, loadingOptions) {
9
- const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {});
10
- const realLoadingOptions = computed(() => ({
11
- ...toValue(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
- };
@@ -1,6 +0,0 @@
1
- import type { InjectionKey } from 'vue';
2
- import type { ThemeInjection, InitOptionsInjection, UpdateOptionsInjection } from '../types.js';
3
- export declare const THEME_KEY: InjectionKey<ThemeInjection>;
4
- export declare const INIT_OPTIONS_KEY: InjectionKey<InitOptionsInjection>;
5
- export declare const UPDATE_OPTIONS_KEY: InjectionKey<UpdateOptionsInjection>;
6
- export { LOADING_OPTIONS_KEY } from '../composables/index.js';
@@ -1,4 +0,0 @@
1
- export const THEME_KEY = Symbol();
2
- export const INIT_OPTIONS_KEY = Symbol();
3
- export const UPDATE_OPTIONS_KEY = Symbol();
4
- export { LOADING_OPTIONS_KEY } from "../composables/index.js";
@@ -1,4 +0,0 @@
1
- export declare const isOn: (key: string) => boolean;
2
- type Attrs = Record<string, any>;
3
- export declare function omitOn(attrs: Attrs): Attrs;
4
- export {};
@@ -1,11 +0,0 @@
1
- const onRE = /^on[^a-z]/;
2
- export const isOn = (key) => onRE.test(key);
3
- export function omitOn(attrs) {
4
- const result = {};
5
- for (const key in attrs) {
6
- if (!isOn(key)) {
7
- result[key] = attrs[key];
8
- }
9
- }
10
- return result;
11
- }
@@ -1,6 +0,0 @@
1
- export declare const TAG_NAME = "x-vue-echarts";
2
- export declare class EChartsElement extends HTMLElement {
3
- __dispose: (() => void) | null;
4
- disconnectedCallback(): void;
5
- }
6
- export declare function register(): boolean;
@@ -1,28 +0,0 @@
1
- let registered = null;
2
- export const TAG_NAME = "x-vue-echarts";
3
- if (typeof HTMLElement === "undefined") {
4
- globalThis.HTMLElement = Object;
5
- registered = false;
6
- }
7
- export class EChartsElement extends HTMLElement {
8
- __dispose = null;
9
- disconnectedCallback() {
10
- if (this.__dispose) {
11
- this.__dispose();
12
- this.__dispose = null;
13
- }
14
- }
15
- }
16
- export function register() {
17
- if (registered != null) {
18
- return registered;
19
- }
20
- try {
21
- if (customElements.get(TAG_NAME) == null) {
22
- customElements.define(TAG_NAME, EChartsElement);
23
- }
24
- } catch {
25
- return registered = false;
26
- }
27
- return registered = true;
28
- }