@vtj/charts 0.12.23 → 0.12.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +33 -33
- package/dist/index.umd.js +2 -2
- package/package.json +3 -3
- package/types/version.d.ts +2 -2
package/dist/index.mjs
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
import * as h from "echarts";
|
2
2
|
import { reactive as w, ref as f, onMounted as v, unref as b, markRaw as S, onUnmounted as d, watch as p, shallowRef as j, defineComponent as g, h as m, toRefs as y, computed as C } from "vue";
|
3
3
|
import { useResizeObserver as E } from "@vueuse/core";
|
4
|
-
import { kebabCase as
|
4
|
+
import { kebabCase as x, camelCase as M, debounce as k } from "@vtj/utils";
|
5
5
|
/**!
|
6
6
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
7
7
|
* @name @vtj/charts
|
8
8
|
* @author CHC chenhuachun1549@dingtalk.com
|
9
|
-
* @version 0.12.
|
9
|
+
* @version 0.12.25
|
10
10
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
11
11
|
*/
|
12
|
-
const
|
13
|
-
function J(
|
12
|
+
const T = "0.12.25";
|
13
|
+
function J(s) {
|
14
14
|
const o = w({});
|
15
|
-
for (const [u, e] of Object.entries(
|
16
|
-
const [r, ...
|
15
|
+
for (const [u, e] of Object.entries(s)) {
|
16
|
+
const [r, ...a] = x(u).split("-");
|
17
17
|
if (r === "on" && typeof e == "function") {
|
18
|
-
const t =
|
18
|
+
const t = M(a.join("-"));
|
19
19
|
o[t] = e;
|
20
20
|
}
|
21
21
|
}
|
22
22
|
return o;
|
23
23
|
}
|
24
|
-
function L(
|
24
|
+
function L(s, o, u) {
|
25
25
|
const e = f(), r = J(u);
|
26
26
|
return v(() => {
|
27
|
-
const t = b(
|
27
|
+
const t = b(s);
|
28
28
|
if (t && (e.value || (e.value = S(h.init(t))), e.value)) {
|
29
29
|
for (const [i, n] of Object.entries(r))
|
30
30
|
e.value.on(i, n);
|
@@ -43,7 +43,7 @@ function L(a, o, u) {
|
|
43
43
|
},
|
44
44
|
{ deep: !0 }
|
45
45
|
), E(
|
46
|
-
|
46
|
+
s,
|
47
47
|
k(() => {
|
48
48
|
e.value && e.value.resize();
|
49
49
|
}, 150)
|
@@ -52,31 +52,31 @@ function L(a, o, u) {
|
|
52
52
|
getEChart: () => e.value
|
53
53
|
};
|
54
54
|
}
|
55
|
-
function X(
|
56
|
-
const e = f(), r = j(null),
|
55
|
+
function X(s, o, u) {
|
56
|
+
const e = f(), r = j(null), a = f({}), t = async (i, n) => {
|
57
57
|
const c = e.value?.instance;
|
58
58
|
c && c.showLoading();
|
59
59
|
const l = typeof n == "string" ? await fetch(n).then((O) => O.json()).catch(() => null) : n;
|
60
60
|
return c && c.hideLoading(), l && h.registerMap(i, l), l;
|
61
61
|
};
|
62
|
-
return p([
|
63
|
-
r.value = await t(
|
62
|
+
return p([s, o], async () => {
|
63
|
+
r.value = await t(s.value, o.value);
|
64
64
|
}), p(r, (i) => {
|
65
65
|
if (i) {
|
66
66
|
const n = u.option || {};
|
67
|
-
n.geo && (n.geo.map =
|
68
|
-
l?.type === "map" && (l.map =
|
69
|
-
}),
|
67
|
+
n.geo && (n.geo.map = s.value), (n.series || []).map((l) => {
|
68
|
+
l?.type === "map" && (l.map = s.value);
|
69
|
+
}), a.value = n;
|
70
70
|
}
|
71
71
|
}), v(async () => {
|
72
|
-
r.value = await t(
|
72
|
+
r.value = await t(s.value, o.value);
|
73
73
|
}), d(() => {
|
74
74
|
const i = e.value?.instance;
|
75
75
|
i && i.hideLoading();
|
76
76
|
}), {
|
77
77
|
chartRef: e,
|
78
78
|
geoJSON: r,
|
79
|
-
option:
|
79
|
+
option: a
|
80
80
|
};
|
81
81
|
}
|
82
82
|
const R = g({
|
@@ -94,19 +94,19 @@ const R = g({
|
|
94
94
|
type: Object
|
95
95
|
}
|
96
96
|
},
|
97
|
-
setup(
|
98
|
-
const { width: e, height: r, option:
|
97
|
+
setup(s, { expose: o, attrs: u }) {
|
98
|
+
const { width: e, height: r, option: a } = y(s), t = f(), i = C(() => ({
|
99
99
|
width: e.value,
|
100
100
|
height: r.value
|
101
|
-
})), { instance: n, getEChart: c } = L(t,
|
101
|
+
})), { instance: n, getEChart: c } = L(t, a, u);
|
102
102
|
return o({
|
103
103
|
elRef: t,
|
104
|
-
option:
|
104
|
+
option: a,
|
105
105
|
instance: n,
|
106
106
|
getEChart: c
|
107
107
|
}), {
|
108
108
|
elRef: t,
|
109
|
-
option:
|
109
|
+
option: a,
|
110
110
|
styles: i,
|
111
111
|
instance: n,
|
112
112
|
getEChart: c
|
@@ -115,7 +115,7 @@ const R = g({
|
|
115
115
|
render() {
|
116
116
|
return m("div", { class: "x-chart", ref: "elRef", style: this.styles });
|
117
117
|
}
|
118
|
-
}),
|
118
|
+
}), N = g({
|
119
119
|
name: "XMapChart",
|
120
120
|
inheritAttrs: !1,
|
121
121
|
props: {
|
@@ -129,16 +129,16 @@ const R = g({
|
|
129
129
|
}
|
130
130
|
},
|
131
131
|
emits: ["ready"],
|
132
|
-
async setup(
|
133
|
-
const { name: e, geoJson: r } = y(
|
132
|
+
async setup(s, { attrs: o, emit: u }) {
|
133
|
+
const { name: e, geoJson: r } = y(s), { chartRef: a, geoJSON: t, option: i } = X(e, r, o), n = C(() => a.value?.instance);
|
134
134
|
return p(t, async (c) => {
|
135
135
|
c && u("ready", c);
|
136
136
|
}), {
|
137
|
-
chartRef:
|
137
|
+
chartRef: a,
|
138
138
|
option: i,
|
139
139
|
instance: n,
|
140
|
-
getChartRef: () =>
|
141
|
-
getEChart: () =>
|
140
|
+
getChartRef: () => a.value,
|
141
|
+
getEChart: () => a.value?.getEChart(),
|
142
142
|
geoJSON: t
|
143
143
|
};
|
144
144
|
},
|
@@ -155,11 +155,11 @@ const R = g({
|
|
155
155
|
);
|
156
156
|
},
|
157
157
|
methods: {}
|
158
|
-
}), V = [R];
|
158
|
+
}), V = [R, N];
|
159
159
|
export {
|
160
|
-
|
160
|
+
T as VTJ_CHARTS_VERSION,
|
161
161
|
R as XChart,
|
162
|
-
|
162
|
+
N as XMapChart,
|
163
163
|
V as components,
|
164
164
|
h as echarts
|
165
165
|
};
|
package/dist/index.umd.js
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/charts
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.12.
|
5
|
+
* @version 0.12.25
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
|
-
*/const h="0.12.
|
7
|
+
*/const h="0.12.25";function m(t){const s=Vue.reactive({});for(const[l,e]of Object.entries(t)){const[u,...i]=VtjUtils.kebabCase(l).split("-");if(u==="on"&&typeof e=="function"){const n=VtjUtils.camelCase(i.join("-"));s[n]=e}}return s}function y(t,s,l){const e=Vue.ref(),u=m(l);return Vue.onMounted(()=>{const n=Vue.unref(t);if(n&&(e.value||(e.value=Vue.markRaw(echarts.init(n))),e.value)){for(const[c,a]of Object.entries(u))e.value.on(c,a);e.value.setOption(s.value||{})}}),Vue.onUnmounted(()=>{if(e.value){for(const n of Object.keys(u))e.value.off(n);e.value.dispose()}}),Vue.watch(s,async n=>{e.value&&e.value.setOption(n||{})},{deep:!0}),VueUse.useResizeObserver(t,VtjUtils.debounce(()=>{e.value&&e.value.resize()},150)),{instance:e,getEChart:()=>e.value}}function C(t,s,l){const e=Vue.ref(),u=Vue.shallowRef(null),i=Vue.ref({}),n=async(c,a)=>{var V;const o=(V=e.value)==null?void 0:V.instance;o&&o.showLoading();const f=typeof a=="string"?await fetch(a).then(j=>j.json()).catch(()=>null):a;return o&&o.hideLoading(),f&&echarts.registerMap(c,f),f};return Vue.watch([t,s],async()=>{u.value=await n(t.value,s.value)}),Vue.watch(u,c=>{if(c){const a=l.option||{};a.geo&&(a.geo.map=t.value),(a.series||[]).map(f=>{(f==null?void 0:f.type)==="map"&&(f.map=t.value)}),i.value=a}}),Vue.onMounted(async()=>{u.value=await n(t.value,s.value)}),Vue.onUnmounted(()=>{var a;const c=(a=e.value)==null?void 0:a.instance;c&&c.hideLoading()}),{chartRef:e,geoJSON:u,option:i}}const p=Vue.defineComponent({name:"XChart",props:{width:{type:String,default:"100%"},height:{type:String,default:"400px"},option:{type:Object}},setup(t,{expose:s,attrs:l}){const{width:e,height:u,option:i}=Vue.toRefs(t),n=Vue.ref(),c=Vue.computed(()=>({width:e.value,height:u.value})),{instance:a,getEChart:o}=y(n,i,l);return s({elRef:n,option:i,instance:a,getEChart:o}),{elRef:n,option:i,styles:c,instance:a,getEChart:o}},render(){return Vue.h("div",{class:"x-chart",ref:"elRef",style:this.styles})}}),v=Vue.defineComponent({name:"XMapChart",inheritAttrs:!1,props:{geoJson:{type:[String,Object],default:"https://unpkg.com/vtj-geojson@0.1.3/geo/100000/100000.geoJson"},name:{type:String,default:"china"}},emits:["ready"],async setup(t,{attrs:s,emit:l}){const{name:e,geoJson:u}=Vue.toRefs(t),{chartRef:i,geoJSON:n,option:c}=C(e,u,s),a=Vue.computed(()=>{var o;return(o=i.value)==null?void 0:o.instance});return Vue.watch(n,async o=>{o&&l("ready",o)}),{chartRef:i,option:c,instance:a,getChartRef:()=>i.value,getEChart:()=>{var o;return(o=i.value)==null?void 0:o.getEChart()},geoJSON:n}},render(){return Vue.h(p,{...this.$attrs,ref:"chartRef",class:"x-map-chart",option:this.option},this.$slots)},methods:{}}),g=[p,v];var b=echarts;const d=Symbol("INSTALLED_KEY");function S(t){t[d]||(t[d]=!0,g.forEach(s=>{s.name&&t.component(s.name,s)}))}r.INSTALLED_KEY=d,r.VTJ_CHARTS_VERSION=h,r.XChart=p,r.XMapChart=v,r.components=g,r.echarts=b,r.install=S,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vtj/charts",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.12.
|
4
|
+
"version": "0.12.25",
|
5
5
|
"type": "module",
|
6
6
|
"keywords": [
|
7
7
|
"低代码引擎",
|
@@ -26,8 +26,8 @@
|
|
26
26
|
"dependencies": {
|
27
27
|
"@vueuse/core": "~13.1.0",
|
28
28
|
"echarts": "~5.6.0",
|
29
|
-
"@vtj/utils": "~0.12.
|
30
|
-
"@vtj/icons": "~0.12.
|
29
|
+
"@vtj/utils": "~0.12.25",
|
30
|
+
"@vtj/icons": "~0.12.25"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
33
|
"@vtj/cli": "~0.12.2"
|
package/types/version.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Copyright (c) 2025, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/charts
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.12.
|
5
|
+
* @version 0.12.24
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
7
|
*/
|
8
|
-
export declare const version = "0.12.
|
8
|
+
export declare const version = "0.12.24";
|