@vtj/charts 0.12.22 → 0.12.24

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 CHANGED
@@ -1,31 +1,31 @@
1
- import * as v from "echarts";
2
- import { reactive as w, ref as f, onMounted as h, 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";
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
- import { kebabCase as M, camelCase as x, debounce as k } from "@vtj/utils";
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.22
9
+ * @version 0.12.24
10
10
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
11
11
  */
12
- const I = "0.12.22";
13
- function J(a) {
12
+ const T = "0.12.24";
13
+ function J(s) {
14
14
  const o = w({});
15
- for (const [c, e] of Object.entries(a)) {
16
- const [r, ...s] = M(c).split("-");
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 = x(s.join("-"));
18
+ const t = M(a.join("-"));
19
19
  o[t] = e;
20
20
  }
21
21
  }
22
22
  return o;
23
23
  }
24
- function L(a, o, c) {
25
- const e = f(), r = J(c);
26
- return h(() => {
27
- const t = b(a);
28
- if (t && (e.value || (e.value = S(v.init(t))), e.value)) {
24
+ function L(s, o, u) {
25
+ const e = f(), r = J(u);
26
+ return v(() => {
27
+ const t = b(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 || {});
@@ -43,7 +43,7 @@ function L(a, o, c) {
43
43
  },
44
44
  { deep: !0 }
45
45
  ), E(
46
- a,
46
+ s,
47
47
  k(() => {
48
48
  e.value && e.value.resize();
49
49
  }, 150)
@@ -52,31 +52,31 @@ function L(a, o, c) {
52
52
  getEChart: () => e.value
53
53
  };
54
54
  }
55
- function X(a, o, c) {
56
- const e = f(), r = j(null), s = f({}), t = async (i, n) => {
57
- const u = e.value?.instance;
58
- u && u.showLoading();
55
+ function X(s, o, u) {
56
+ const e = f(), r = j(null), a = f({}), t = async (i, n) => {
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 u && u.hideLoading(), l && v.registerMap(i, l), l;
60
+ return c && c.hideLoading(), l && h.registerMap(i, l), l;
61
61
  };
62
- return p([a, o], async () => {
63
- r.value = await t(a.value, o.value);
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
- const n = c.option || {};
67
- n.geo && (n.geo.map = a.value), (n.series || []).map((l) => {
68
- l?.type === "map" && (l.map = a.value);
69
- }), s.value = n;
66
+ const n = u.option || {};
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
- }), h(async () => {
72
- r.value = await t(a.value, o.value);
71
+ }), v(async () => {
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: s
79
+ option: a
80
80
  };
81
81
  }
82
82
  const R = g({
@@ -94,28 +94,28 @@ const R = g({
94
94
  type: Object
95
95
  }
96
96
  },
97
- setup(a, { expose: o, attrs: c }) {
98
- const { width: e, height: r, option: s } = y(a), t = f(), i = C(() => ({
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: u } = L(t, s, c);
101
+ })), { instance: n, getEChart: c } = L(t, a, u);
102
102
  return o({
103
103
  elRef: t,
104
- option: s,
104
+ option: a,
105
105
  instance: n,
106
- getEChart: u
106
+ getEChart: c
107
107
  }), {
108
108
  elRef: t,
109
- option: s,
109
+ option: a,
110
110
  styles: i,
111
111
  instance: n,
112
- getEChart: u
112
+ getEChart: c
113
113
  };
114
114
  },
115
115
  render() {
116
116
  return m("div", { class: "x-chart", ref: "elRef", style: this.styles });
117
117
  }
118
- }), T = g({
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(a, { attrs: o, emit: c }) {
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 h(() => {
135
- c("ready", n.value);
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
+ return p(t, async (c) => {
135
+ c && u("ready", c);
136
136
  }), {
137
- chartRef: s,
137
+ chartRef: a,
138
138
  option: i,
139
139
  instance: n,
140
- getChartRef: () => s.value,
141
- getEChart: () => s.value?.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
- I as VTJ_CHARTS_VERSION,
160
+ T as VTJ_CHARTS_VERSION,
161
161
  R as XChart,
162
- T as XMapChart,
162
+ N as XMapChart,
163
163
  V as components,
164
- v as echarts
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.22
5
+ * @version 0.12.24
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const h="0.12.22";function V(n){const a=Vue.reactive({});for(const[l,e]of Object.entries(n)){const[i,...o]=VtjUtils.kebabCase(l).split("-");if(i==="on"&&typeof e=="function"){const s=VtjUtils.camelCase(o.join("-"));a[s]=e}}return a}function m(n,a,l){const e=Vue.ref(),i=V(l);return Vue.onMounted(()=>{const s=Vue.unref(n);if(s&&(e.value||(e.value=Vue.markRaw(echarts.init(s))),e.value)){for(const[c,t]of Object.entries(i))e.value.on(c,t);e.value.setOption(a.value||{})}}),Vue.onUnmounted(()=>{if(e.value){for(const s of Object.keys(i))e.value.off(s);e.value.dispose()}}),Vue.watch(a,async s=>{e.value&&e.value.setOption(s||{})},{deep:!0}),VueUse.useResizeObserver(n,VtjUtils.debounce(()=>{e.value&&e.value.resize()},150)),{instance:e,getEChart:()=>e.value}}function y(n,a,l){const e=Vue.ref(),i=Vue.shallowRef(null),o=Vue.ref({}),s=async(c,t)=>{var g;const u=(g=e.value)==null?void 0:g.instance;u&&u.showLoading();const f=typeof t=="string"?await fetch(t).then(j=>j.json()).catch(()=>null):t;return u&&u.hideLoading(),f&&echarts.registerMap(c,f),f};return Vue.watch([n,a],async()=>{i.value=await s(n.value,a.value)}),Vue.watch(i,c=>{if(c){const t=l.option||{};t.geo&&(t.geo.map=n.value),(t.series||[]).map(f=>{(f==null?void 0:f.type)==="map"&&(f.map=n.value)}),o.value=t}}),Vue.onMounted(async()=>{i.value=await s(n.value,a.value)}),Vue.onUnmounted(()=>{var t;const c=(t=e.value)==null?void 0:t.instance;c&&c.hideLoading()}),{chartRef:e,geoJSON:i,option:o}}const p=Vue.defineComponent({name:"XChart",props:{width:{type:String,default:"100%"},height:{type:String,default:"400px"},option:{type:Object}},setup(n,{expose:a,attrs:l}){const{width:e,height:i,option:o}=Vue.toRefs(n),s=Vue.ref(),c=Vue.computed(()=>({width:e.value,height:i.value})),{instance:t,getEChart:u}=m(s,o,l);return a({elRef:s,option:o,instance:t,getEChart:u}),{elRef:s,option:o,styles:c,instance:t,getEChart:u}},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(n,{attrs:a,emit:l}){const{name:e,geoJson:i}=Vue.toRefs(n),{chartRef:o,geoJSON:s,option:c}=y(e,i,a),t=Vue.computed(()=>{var u;return(u=o.value)==null?void 0:u.instance});return Vue.onMounted(()=>{l("ready",t.value)}),{chartRef:o,option:c,instance:t,getChartRef:()=>o.value,getEChart:()=>{var u;return(u=o.value)==null?void 0:u.getEChart()},geoJSON:s}},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(n){n[d]||(n[d]=!0,v.forEach(a=>{a.name&&n.component(a.name,a)}))}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"})});
7
+ */const h="0.12.24";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.22",
4
+ "version": "0.12.24",
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/icons": "~0.12.22",
30
- "@vtj/utils": "~0.12.22"
29
+ "@vtj/icons": "~0.12.24",
30
+ "@vtj/utils": "~0.12.24"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@vtj/cli": "~0.12.2"
@@ -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.21
5
+ * @version 0.12.23
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.12.21";
8
+ export declare const version = "0.12.23";