nuxt-echarts 0.0.8 → 0.0.9
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/LICENSE +21 -21
- package/dist/module.json +1 -1
- package/dist/runtime/components/VChart.server.vue +5 -5
- package/dist/runtime/components/VChartIsland.server.vue +34 -34
- package/dist/runtime/components/VChartLight.vue +59 -57
- package/dist/runtime/components/VChartLight.vue.d.ts +101 -19
- package/dist/runtime/components/VChartServer.vue +50 -50
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 - present, Yue JIN
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 - present, Yue JIN
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script setup lang="ts"></script>
|
|
2
|
-
|
|
3
|
-
<template>
|
|
4
|
-
<VChartServer v-bind="$attrs" />
|
|
5
|
-
</template>
|
|
1
|
+
<script setup lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<template>
|
|
4
|
+
<VChartServer v-bind="$attrs" />
|
|
5
|
+
</template>
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import * as echarts from 'echarts'
|
|
3
|
-
import { ref } from 'vue'
|
|
4
|
-
import type { Option, InitOptions, Theme } from '../types'
|
|
5
|
-
|
|
6
|
-
const props = defineProps<{
|
|
7
|
-
option?: Option
|
|
8
|
-
initOptions?: InitOptions
|
|
9
|
-
theme?: Theme
|
|
10
|
-
}>()
|
|
11
|
-
|
|
12
|
-
const svgStr = ref('')
|
|
13
|
-
const initOptions: InitOptions = echarts.util.merge(
|
|
14
|
-
{ renderer: 'svg', ssr: true } satisfies InitOptions,
|
|
15
|
-
props.initOptions || {},
|
|
16
|
-
)
|
|
17
|
-
let chart = echarts.init(null, props.theme, initOptions)
|
|
18
|
-
chart.setOption(props.option || {})
|
|
19
|
-
svgStr.value = chart.renderToSVGString()
|
|
20
|
-
|
|
21
|
-
chart.dispose()
|
|
22
|
-
|
|
23
|
-
// @ts-expect-error release memory
|
|
24
|
-
chart = null
|
|
25
|
-
|
|
26
|
-
defineSlots<{ fallback: any }>()
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<template>
|
|
30
|
-
<div class="vue-echarts-container">
|
|
31
|
-
<!--eslint-disable-next-line vue/no-v-html-->
|
|
32
|
-
<div class="vue-echarts-inner" v-html="svgStr" />
|
|
33
|
-
</div>
|
|
34
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import * as echarts from 'echarts'
|
|
3
|
+
import { ref } from 'vue'
|
|
4
|
+
import type { Option, InitOptions, Theme } from '../types'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
option?: Option
|
|
8
|
+
initOptions?: InitOptions
|
|
9
|
+
theme?: Theme
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const svgStr = ref('')
|
|
13
|
+
const initOptions: InitOptions = echarts.util.merge(
|
|
14
|
+
{ renderer: 'svg', ssr: true } satisfies InitOptions,
|
|
15
|
+
props.initOptions || {},
|
|
16
|
+
)
|
|
17
|
+
let chart = echarts.init(null, props.theme, initOptions)
|
|
18
|
+
chart.setOption(props.option || {})
|
|
19
|
+
svgStr.value = chart.renderToSVGString()
|
|
20
|
+
|
|
21
|
+
chart.dispose()
|
|
22
|
+
|
|
23
|
+
// @ts-expect-error release memory
|
|
24
|
+
chart = null
|
|
25
|
+
|
|
26
|
+
defineSlots<{ fallback: any }>()
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<div class="vue-echarts-container">
|
|
31
|
+
<!--eslint-disable-next-line vue/no-v-html-->
|
|
32
|
+
<div class="vue-echarts-inner" v-html="svgStr" />
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
hydrate
|
|
4
|
+
} from "echarts/ssr/client/index";
|
|
5
|
+
import {
|
|
6
|
+
useAttrs,
|
|
7
|
+
nextTick,
|
|
8
|
+
ref,
|
|
9
|
+
onMounted,
|
|
10
|
+
defineComponent
|
|
11
|
+
} from "vue";
|
|
3
12
|
export default defineComponent({
|
|
4
13
|
inheritAttrs: false,
|
|
5
|
-
|
|
14
|
+
props: {
|
|
15
|
+
option: Object,
|
|
16
|
+
theme: {
|
|
17
|
+
type: [Object, String]
|
|
18
|
+
},
|
|
19
|
+
initOptions: Object
|
|
20
|
+
},
|
|
21
|
+
emits: {},
|
|
22
|
+
setup() {
|
|
23
|
+
const root = ref(null);
|
|
24
|
+
const attrs = useAttrs();
|
|
25
|
+
let container;
|
|
26
|
+
function hydrateChart() {
|
|
27
|
+
container = root.value?.$el;
|
|
28
|
+
if (container) {
|
|
29
|
+
hydrate(container, {
|
|
30
|
+
on: {
|
|
31
|
+
click: attrs.onClick,
|
|
32
|
+
mouseout: attrs.onMouseout,
|
|
33
|
+
mouseover: attrs.onMouseover
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let observer;
|
|
39
|
+
onMounted(async () => {
|
|
40
|
+
await nextTick();
|
|
41
|
+
hydrateChart();
|
|
42
|
+
observer = new MutationObserver(async () => {
|
|
43
|
+
hydrateChart();
|
|
44
|
+
});
|
|
45
|
+
observer.observe(root.value.$el, {
|
|
46
|
+
characterData: false,
|
|
47
|
+
childList: true,
|
|
48
|
+
attributes: false
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return { root };
|
|
52
|
+
}
|
|
6
53
|
});
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type ECSSREventOn = `on${Capitalize<ECSSREvent>}`
|
|
18
|
-
|
|
19
|
-
const root = ref<InstanceType<typeof VChartServer> | null>(null)
|
|
20
|
-
const attrs = useAttrs() as Partial<Record<ECSSREventOn, ECSSRHandler>>
|
|
21
|
-
let container: HTMLElement
|
|
22
|
-
function hydrateChart() {
|
|
23
|
-
container = root.value?.$el
|
|
24
|
-
if (container) {
|
|
25
|
-
// Use the lightweight runtime to give the chart interactive capabilities
|
|
26
|
-
hydrate(container, {
|
|
27
|
-
on: {
|
|
28
|
-
click: attrs.onClick,
|
|
29
|
-
mouseout: attrs.onMouseout,
|
|
30
|
-
mouseover: attrs.onMouseover,
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let observer: MutationObserver
|
|
37
|
-
onMounted(async () => {
|
|
38
|
-
await nextTick()
|
|
39
|
-
hydrateChart()
|
|
40
|
-
observer = new MutationObserver(async () => {
|
|
41
|
-
hydrateChart()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// call 'observe' on that MutationObserver instance,
|
|
45
|
-
// passing it the element to observe, and the options object
|
|
46
|
-
observer.observe(root.value!.$el, {
|
|
47
|
-
characterData: false,
|
|
48
|
-
childList: true,
|
|
49
|
-
attributes: false,
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<template>
|
|
55
|
-
<VChartServer
|
|
56
|
-
ref="root"
|
|
57
|
-
:option="option"
|
|
58
|
-
:init-options="initOptions"
|
|
59
|
-
:theme="theme"
|
|
60
|
-
/>
|
|
61
|
-
</template>
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<VChartServer
|
|
58
|
+
ref="root"
|
|
59
|
+
:option="option"
|
|
60
|
+
:init-options="initOptions"
|
|
61
|
+
:theme="theme"
|
|
62
|
+
/>
|
|
63
|
+
</template>
|
|
@@ -1,26 +1,108 @@
|
|
|
1
1
|
import { type ECSSRClientEventParams, type ECSSREvent } from 'echarts/ssr/client/index';
|
|
2
2
|
import type { InitOptions, Option, Theme } from '../types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
initOptions
|
|
11
|
-
}
|
|
3
|
+
import { nextTick, type PropType } from 'vue';
|
|
4
|
+
type ECSSRHandler = (params: ECSSRClientEventParams) => string | undefined;
|
|
5
|
+
declare const _default: import("vue").DefineComponent<{
|
|
6
|
+
option: PropType<Option>;
|
|
7
|
+
theme: {
|
|
8
|
+
type: PropType<Theme>;
|
|
9
|
+
};
|
|
10
|
+
initOptions: PropType<InitOptions>;
|
|
11
|
+
}, {
|
|
12
|
+
root: import("vue").Ref<({
|
|
13
|
+
$: import("vue").ComponentInternalInstance;
|
|
14
|
+
$data: {};
|
|
15
|
+
$props: Partial<{}> & Omit<{
|
|
16
|
+
readonly option?: Option;
|
|
17
|
+
readonly theme?: Theme;
|
|
18
|
+
readonly initOptions?: InitOptions;
|
|
19
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
20
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
option: {
|
|
22
|
+
type: PropType<import("echarts/core").EChartsCoreOption>;
|
|
23
|
+
};
|
|
24
|
+
theme: {
|
|
25
|
+
type: PropType<Theme>;
|
|
26
|
+
};
|
|
27
|
+
initOptions: {
|
|
28
|
+
type: PropType<import("echarts/core").EChartsInitOpts>;
|
|
29
|
+
};
|
|
30
|
+
}>> & {
|
|
31
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
32
|
+
}, never>;
|
|
33
|
+
$attrs: {
|
|
34
|
+
[x: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
$refs: {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
$slots: Readonly<{
|
|
40
|
+
[name: string]: import("vue").Slot<any> | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
$root: import("vue").ComponentPublicInstance | null;
|
|
43
|
+
$parent: import("vue").ComponentPublicInstance | null;
|
|
44
|
+
$emit: (event: "error", error: unknown) => void;
|
|
45
|
+
$el: any;
|
|
46
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
47
|
+
option: {
|
|
48
|
+
type: PropType<import("echarts/core").EChartsCoreOption>;
|
|
49
|
+
};
|
|
50
|
+
theme: {
|
|
51
|
+
type: PropType<Theme>;
|
|
52
|
+
};
|
|
53
|
+
initOptions: {
|
|
54
|
+
type: PropType<import("echarts/core").EChartsInitOpts>;
|
|
55
|
+
};
|
|
56
|
+
}>> & {
|
|
57
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
58
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
59
|
+
error: (error: unknown) => void;
|
|
60
|
+
}, string, {}, {}, string, {}> & {
|
|
61
|
+
beforeCreate?: (() => void) | (() => void)[];
|
|
62
|
+
created?: (() => void) | (() => void)[];
|
|
63
|
+
beforeMount?: (() => void) | (() => void)[];
|
|
64
|
+
mounted?: (() => void) | (() => void)[];
|
|
65
|
+
beforeUpdate?: (() => void) | (() => void)[];
|
|
66
|
+
updated?: (() => void) | (() => void)[];
|
|
67
|
+
activated?: (() => void) | (() => void)[];
|
|
68
|
+
deactivated?: (() => void) | (() => void)[];
|
|
69
|
+
beforeDestroy?: (() => void) | (() => void)[];
|
|
70
|
+
beforeUnmount?: (() => void) | (() => void)[];
|
|
71
|
+
destroyed?: (() => void) | (() => void)[];
|
|
72
|
+
unmounted?: (() => void) | (() => void)[];
|
|
73
|
+
renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
|
|
74
|
+
renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
|
|
75
|
+
errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
|
|
76
|
+
};
|
|
77
|
+
$forceUpdate: () => void;
|
|
78
|
+
$nextTick: typeof nextTick;
|
|
79
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, (cleanupFn: () => void) => void]) => any : (...args: [any, any, (cleanupFn: () => void) => void]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
80
|
+
} & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
81
|
+
option: {
|
|
82
|
+
type: PropType<import("echarts/core").EChartsCoreOption>;
|
|
83
|
+
};
|
|
84
|
+
theme: {
|
|
85
|
+
type: PropType<Theme>;
|
|
86
|
+
};
|
|
87
|
+
initOptions: {
|
|
88
|
+
type: PropType<import("echarts/core").EChartsInitOpts>;
|
|
89
|
+
};
|
|
90
|
+
}>> & {
|
|
91
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
92
|
+
}, never> & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties & {} & {
|
|
93
|
+
$slots: {
|
|
94
|
+
fallback?(_: {}): any;
|
|
95
|
+
};
|
|
96
|
+
}) | null>;
|
|
97
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<ECSSREvent, ECSSRHandler>, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
98
|
+
option: PropType<Option>;
|
|
99
|
+
theme: {
|
|
100
|
+
type: PropType<Theme>;
|
|
101
|
+
};
|
|
102
|
+
initOptions: PropType<InitOptions>;
|
|
103
|
+
}>> & {
|
|
12
104
|
onClick?: ((params: ECSSRClientEventParams) => any) | undefined;
|
|
13
105
|
onMouseout?: ((params: ECSSRClientEventParams) => any) | undefined;
|
|
14
106
|
onMouseover?: ((params: ECSSRClientEventParams) => any) | undefined;
|
|
15
107
|
}, {}, {}>;
|
|
16
108
|
export default _default;
|
|
17
|
-
|
|
18
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
19
|
-
type __VLS_TypePropsToOption<T> = {
|
|
20
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
21
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
22
|
-
} : {
|
|
23
|
-
type: import('vue').PropType<T[K]>;
|
|
24
|
-
required: true;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, unref, inject, ref } from 'vue'
|
|
3
|
-
import type { InitOptions, Option, Theme } from '../types'
|
|
4
|
-
import { THEME_KEY, INIT_OPTIONS_KEY } from '../utils/injection'
|
|
5
|
-
import type VChartIsland from './VChartLight.vue'
|
|
6
|
-
|
|
7
|
-
const defaultTheme = inject(THEME_KEY, null)
|
|
8
|
-
const defaultInitOptions = inject(INIT_OPTIONS_KEY, null)
|
|
9
|
-
|
|
10
|
-
const props = defineProps<{
|
|
11
|
-
option?: Option
|
|
12
|
-
theme?: Theme
|
|
13
|
-
initOptions?: InitOptions
|
|
14
|
-
}>()
|
|
15
|
-
const emits = defineEmits<{ (event: 'error', error: unknown): void }>()
|
|
16
|
-
|
|
17
|
-
const realTheme = computed(() => props.theme || unref(defaultTheme) || {})
|
|
18
|
-
const realInitOptions = computed(
|
|
19
|
-
// @ts-expect-error unknown computed type error
|
|
20
|
-
() => props.initOptions || unref(defaultInitOptions) || {},
|
|
21
|
-
)
|
|
22
|
-
function onError(e: unknown) {
|
|
23
|
-
// https://github.com/nuxt/nuxt/issues/27491
|
|
24
|
-
if (
|
|
25
|
-
e instanceof TypeError &&
|
|
26
|
-
e.message === "Cannot read properties of undefined (reading 'link')"
|
|
27
|
-
) {
|
|
28
|
-
// @ts-expect-error https://github.com/nuxt/nuxt/issues/27730
|
|
29
|
-
root.value.refresh()
|
|
30
|
-
}
|
|
31
|
-
emits('error', e)
|
|
32
|
-
}
|
|
33
|
-
const root = ref<InstanceType<typeof VChartIsland> | null>(null)
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<template>
|
|
37
|
-
<div class="vue-echarts-server">
|
|
38
|
-
<VChartIsland
|
|
39
|
-
ref="root"
|
|
40
|
-
:theme="realTheme"
|
|
41
|
-
:option="option"
|
|
42
|
-
:init-options="realInitOptions"
|
|
43
|
-
@error="onError"
|
|
44
|
-
>
|
|
45
|
-
<template #fallback>
|
|
46
|
-
<slot name="fallback" />
|
|
47
|
-
</template>
|
|
48
|
-
</VChartIsland>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, unref, inject, ref } from 'vue'
|
|
3
|
+
import type { InitOptions, Option, Theme } from '../types'
|
|
4
|
+
import { THEME_KEY, INIT_OPTIONS_KEY } from '../utils/injection'
|
|
5
|
+
import type VChartIsland from './VChartLight.vue'
|
|
6
|
+
|
|
7
|
+
const defaultTheme = inject(THEME_KEY, null)
|
|
8
|
+
const defaultInitOptions = inject(INIT_OPTIONS_KEY, null)
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
option?: Option
|
|
12
|
+
theme?: Theme
|
|
13
|
+
initOptions?: InitOptions
|
|
14
|
+
}>()
|
|
15
|
+
const emits = defineEmits<{ (event: 'error', error: unknown): void }>()
|
|
16
|
+
|
|
17
|
+
const realTheme = computed(() => props.theme || unref(defaultTheme) || {})
|
|
18
|
+
const realInitOptions = computed(
|
|
19
|
+
// @ts-expect-error unknown computed type error
|
|
20
|
+
() => props.initOptions || unref(defaultInitOptions) || {},
|
|
21
|
+
)
|
|
22
|
+
function onError(e: unknown) {
|
|
23
|
+
// https://github.com/nuxt/nuxt/issues/27491
|
|
24
|
+
if (
|
|
25
|
+
e instanceof TypeError &&
|
|
26
|
+
e.message === "Cannot read properties of undefined (reading 'link')"
|
|
27
|
+
) {
|
|
28
|
+
// @ts-expect-error https://github.com/nuxt/nuxt/issues/27730
|
|
29
|
+
root.value.refresh()
|
|
30
|
+
}
|
|
31
|
+
emits('error', e)
|
|
32
|
+
}
|
|
33
|
+
const root = ref<InstanceType<typeof VChartIsland> | null>(null)
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<div class="vue-echarts-server">
|
|
38
|
+
<VChartIsland
|
|
39
|
+
ref="root"
|
|
40
|
+
:theme="realTheme"
|
|
41
|
+
:option="option"
|
|
42
|
+
:init-options="realInitOptions"
|
|
43
|
+
@error="onError"
|
|
44
|
+
>
|
|
45
|
+
<template #fallback>
|
|
46
|
+
<slot name="fallback" />
|
|
47
|
+
</template>
|
|
48
|
+
</VChartIsland>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|