@vtj/charts 0.12.22 → 0.12.23
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 +24 -24
- 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,19 +1,19 @@
|
|
1
|
-
import * as
|
2
|
-
import { reactive as w, ref as f, onMounted as
|
1
|
+
import * as h from "echarts";
|
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
4
|
import { kebabCase as M, camelCase as x, 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.23
|
10
10
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
11
11
|
*/
|
12
|
-
const I = "0.12.
|
12
|
+
const I = "0.12.23";
|
13
13
|
function J(a) {
|
14
14
|
const o = w({});
|
15
|
-
for (const [
|
16
|
-
const [r, ...s] = M(
|
15
|
+
for (const [u, e] of Object.entries(a)) {
|
16
|
+
const [r, ...s] = M(u).split("-");
|
17
17
|
if (r === "on" && typeof e == "function") {
|
18
18
|
const t = x(s.join("-"));
|
19
19
|
o[t] = e;
|
@@ -21,11 +21,11 @@ function J(a) {
|
|
21
21
|
}
|
22
22
|
return o;
|
23
23
|
}
|
24
|
-
function L(a, o,
|
25
|
-
const e = f(), r = J(
|
26
|
-
return
|
24
|
+
function L(a, o, u) {
|
25
|
+
const e = f(), r = J(u);
|
26
|
+
return v(() => {
|
27
27
|
const t = b(a);
|
28
|
-
if (t && (e.value || (e.value = S(
|
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);
|
31
31
|
e.value.setOption(o.value || {});
|
@@ -52,23 +52,23 @@ function L(a, o, c) {
|
|
52
52
|
getEChart: () => e.value
|
53
53
|
};
|
54
54
|
}
|
55
|
-
function X(a, o,
|
55
|
+
function X(a, o, u) {
|
56
56
|
const e = f(), r = j(null), s = f({}), t = async (i, n) => {
|
57
|
-
const
|
58
|
-
|
57
|
+
const c = e.value?.instance;
|
58
|
+
c && c.showLoading();
|
59
59
|
const l = typeof n == "string" ? await fetch(n).then((O) => O.json()).catch(() => null) : n;
|
60
|
-
return
|
60
|
+
return c && c.hideLoading(), l && h.registerMap(i, l), l;
|
61
61
|
};
|
62
62
|
return p([a, o], async () => {
|
63
63
|
r.value = await t(a.value, o.value);
|
64
64
|
}), p(r, (i) => {
|
65
65
|
if (i) {
|
66
|
-
const n =
|
66
|
+
const n = u.option || {};
|
67
67
|
n.geo && (n.geo.map = a.value), (n.series || []).map((l) => {
|
68
68
|
l?.type === "map" && (l.map = a.value);
|
69
69
|
}), s.value = n;
|
70
70
|
}
|
71
|
-
}),
|
71
|
+
}), v(async () => {
|
72
72
|
r.value = await t(a.value, o.value);
|
73
73
|
}), d(() => {
|
74
74
|
const i = e.value?.instance;
|
@@ -94,22 +94,22 @@ const R = g({
|
|
94
94
|
type: Object
|
95
95
|
}
|
96
96
|
},
|
97
|
-
setup(a, { expose: o, attrs:
|
97
|
+
setup(a, { expose: o, attrs: u }) {
|
98
98
|
const { width: e, height: r, option: s } = y(a), t = f(), i = C(() => ({
|
99
99
|
width: e.value,
|
100
100
|
height: r.value
|
101
|
-
})), { instance: n, getEChart:
|
101
|
+
})), { instance: n, getEChart: c } = L(t, s, u);
|
102
102
|
return o({
|
103
103
|
elRef: t,
|
104
104
|
option: s,
|
105
105
|
instance: n,
|
106
|
-
getEChart:
|
106
|
+
getEChart: c
|
107
107
|
}), {
|
108
108
|
elRef: t,
|
109
109
|
option: s,
|
110
110
|
styles: i,
|
111
111
|
instance: n,
|
112
|
-
getEChart:
|
112
|
+
getEChart: c
|
113
113
|
};
|
114
114
|
},
|
115
115
|
render() {
|
@@ -129,10 +129,10 @@ const R = g({
|
|
129
129
|
}
|
130
130
|
},
|
131
131
|
emits: ["ready"],
|
132
|
-
async setup(a, { attrs: o, emit:
|
132
|
+
async setup(a, { attrs: o, emit: u }) {
|
133
133
|
const { name: e, geoJson: r } = y(a), { chartRef: s, geoJSON: t, option: i } = X(e, r, o), n = C(() => s.value?.instance);
|
134
|
-
return
|
135
|
-
c("ready",
|
134
|
+
return p(t, async (c) => {
|
135
|
+
c && u("ready", c);
|
136
136
|
}), {
|
137
137
|
chartRef: s,
|
138
138
|
option: i,
|
@@ -161,5 +161,5 @@ export {
|
|
161
161
|
R as XChart,
|
162
162
|
T 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.23
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
|
-
*/const h="0.12.
|
7
|
+
*/const h="0.12.23";function V(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 m(t,s,l){const e=Vue.ref(),u=V(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 y(t,s,l){const e=Vue.ref(),u=Vue.shallowRef(null),i=Vue.ref({}),n=async(c,a)=>{var g;const o=(g=e.value)==null?void 0:g.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}=m(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})}}),C=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}=y(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:{}}),v=[p];var b=echarts;const d=Symbol("INSTALLED_KEY");function S(t){t[d]||(t[d]=!0,v.forEach(s=>{s.name&&t.component(s.name,s)}))}r.INSTALLED_KEY=d,r.VTJ_CHARTS_VERSION=h,r.XChart=p,r.XMapChart=C,r.components=v,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.23",
|
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/
|
30
|
-
"@vtj/
|
29
|
+
"@vtj/utils": "~0.12.23",
|
30
|
+
"@vtj/icons": "~0.12.23"
|
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.22
|
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.22";
|