@idux/charts-core 0.0.4 → 0.1.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/dist/index.mjs +62 -61
- package/dist/index.umd.js +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { watch as h, shallowRef as v, computed as
|
|
2
|
-
import { throttle as
|
|
3
|
-
import { isEqual as
|
|
4
|
-
function
|
|
5
|
-
let
|
|
1
|
+
import { watch as h, shallowRef as v, computed as l, onMounted as w, onBeforeUnmount as T, watchEffect as E, defineComponent as y, inject as I, h as L, isVue2 as P } from "vue-demi";
|
|
2
|
+
import { throttle as _, init as j } from "echarts/core";
|
|
3
|
+
import { isEqual as H, cloneDeep as x, isObject as M } from "lodash-es";
|
|
4
|
+
function N(e, o, t) {
|
|
5
|
+
let s;
|
|
6
6
|
h(
|
|
7
|
-
[e,
|
|
8
|
-
([
|
|
9
|
-
!
|
|
7
|
+
[e, o, t],
|
|
8
|
+
([n, c, a], f, d) => {
|
|
9
|
+
!n || !c || (a ? (s ?? (s = _(() => c.resize(), 16)), W(n, s)) : z(n, s), d(() => z(n, s)));
|
|
10
10
|
}
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
const p = /* @__PURE__ */ new Map();
|
|
14
|
-
function W(e,
|
|
15
|
-
if (!(!e || !
|
|
14
|
+
function W(e, o, t) {
|
|
15
|
+
if (!(!e || !o))
|
|
16
16
|
if (p.has(e))
|
|
17
|
-
p.get(e).listeners.push(
|
|
17
|
+
p.get(e).listeners.push(o);
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const s = [o], n = new ResizeObserver((c) => {
|
|
20
|
+
c.forEach((a) => s.forEach((f) => f(a)));
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
n.observe(e, t), p.set(e, { listeners: s, ro: n });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
function z(e,
|
|
26
|
-
if (!e || !
|
|
25
|
+
function z(e, o) {
|
|
26
|
+
if (!e || !o || !p.has(e))
|
|
27
27
|
return;
|
|
28
|
-
const { listeners:
|
|
29
|
-
|
|
28
|
+
const { listeners: t, ro: s } = p.get(e), n = t.indexOf(o);
|
|
29
|
+
n > -1 && (t.splice(n, 1), t.length === 0 && (s.disconnect(), p.delete(e)));
|
|
30
30
|
}
|
|
31
31
|
function G(e) {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
32
|
+
const o = v(), t = v(), s = v(), n = l(() => e.value.autoResize ?? !0), c = l(() => e.value.group), a = l(() => e.value.initOption), f = l(() => e.value.loading), d = l(() => e.value.setOptionOpts), m = l(() => e.value.theme), C = () => {
|
|
33
|
+
const i = o.value;
|
|
34
|
+
if (!i)
|
|
35
35
|
return;
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const r = j(i, m.value, a.value), u = e.value, { restOptions: O, events: A } = b(u, !1);
|
|
37
|
+
r.setOption(O, d.value), s.value = x(O), A.forEach(([D, R, S]) => {
|
|
38
38
|
let F = R;
|
|
39
39
|
S && (F = (...B) => {
|
|
40
|
-
R(...B),
|
|
41
|
-
}),
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
|
|
40
|
+
R(...B), r.off(D, F);
|
|
41
|
+
}), r.on(D, F);
|
|
42
|
+
}), u.onReady && u.onReady(r), t.value = r;
|
|
43
|
+
}, g = () => {
|
|
44
|
+
t.value && (t.value.dispose(), t.value = void 0);
|
|
45
45
|
};
|
|
46
|
-
return w(() => C()), T(() =>
|
|
46
|
+
return w(() => C()), T(() => g()), h(
|
|
47
47
|
e,
|
|
48
|
-
(
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
48
|
+
(i) => {
|
|
49
|
+
const r = t.value;
|
|
50
|
+
if (!r)
|
|
51
51
|
return;
|
|
52
|
-
const { restOptions:
|
|
53
|
-
|
|
52
|
+
const { restOptions: u } = b(i);
|
|
53
|
+
H(u, s.value) || (r.setOption(u, d.value), s.value = x(u));
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
deep: !0
|
|
57
57
|
}
|
|
58
58
|
), h(
|
|
59
|
-
[m,
|
|
59
|
+
[m, a],
|
|
60
60
|
() => {
|
|
61
|
-
|
|
61
|
+
g(), C();
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
deep: !0
|
|
65
65
|
}
|
|
66
66
|
), E(() => {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const i = c.value;
|
|
68
|
+
i && t.value && (t.value.group = i);
|
|
69
69
|
}), E(() => {
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
70
|
+
const i = t.value;
|
|
71
|
+
if (!i)
|
|
72
72
|
return;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
}),
|
|
73
|
+
const r = f.value;
|
|
74
|
+
r ? i.showLoading(M(r) ? r : void 0) : i.hideLoading();
|
|
75
|
+
}), N(o, t, n), { containerRef: o, chartRef: t };
|
|
76
76
|
}
|
|
77
77
|
function K(e) {
|
|
78
78
|
return /^on[^a-z]/.test(e);
|
|
@@ -87,35 +87,36 @@ const q = [
|
|
|
87
87
|
"theme",
|
|
88
88
|
"onReady"
|
|
89
89
|
];
|
|
90
|
-
function b(e,
|
|
91
|
-
const
|
|
92
|
-
return Object.keys(e).forEach((
|
|
93
|
-
if (!q.includes(
|
|
94
|
-
if (K(
|
|
95
|
-
if (
|
|
90
|
+
function b(e, o = !0) {
|
|
91
|
+
const t = {}, s = [];
|
|
92
|
+
return Object.keys(e).forEach((n) => {
|
|
93
|
+
if (!q.includes(n)) {
|
|
94
|
+
if (K(n)) {
|
|
95
|
+
if (o)
|
|
96
96
|
return;
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
|
|
97
|
+
const c = e[n];
|
|
98
|
+
if (c) {
|
|
99
|
+
const a = n.endsWith("Once"), f = a ? n.length - 4 : void 0, d = n.charAt(2).toLowerCase() + n.substring(3, f);
|
|
100
|
+
s.push([d, c, a]);
|
|
101
101
|
}
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
n
|
|
104
|
+
t[n] = e[n];
|
|
105
105
|
}
|
|
106
|
-
}), { restOptions:
|
|
106
|
+
}), { restOptions: t, events: s };
|
|
107
107
|
}
|
|
108
108
|
const U = Symbol("CHART_TOKEN"), V = {
|
|
109
109
|
theme: "seer"
|
|
110
110
|
}, J = y({
|
|
111
111
|
name: "IxChart",
|
|
112
112
|
inheritAttrs: !1,
|
|
113
|
-
setup(e, { attrs:
|
|
114
|
-
const
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
113
|
+
setup(e, { attrs: o }) {
|
|
114
|
+
const t = I(U, V), s = l(() => ({ ...t, ...o })), { containerRef: n } = G(s);
|
|
115
|
+
return { containerRef: n, mergedProps: s };
|
|
116
|
+
},
|
|
117
|
+
render() {
|
|
118
|
+
const { class: e, style: o } = this.mergedProps;
|
|
119
|
+
return L("div", P ? { ref: "containerRef", attrs: { class: e, style: o } } : { ref: "containerRef", class: e, style: o });
|
|
119
120
|
}
|
|
120
121
|
}), $ = J, Q = [
|
|
121
122
|
"#458FFF",
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("echarts/core"),require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","vue-demi","echarts/core","lodash-es"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.IduxChartsCore={},c.VueDemi,c.echarts,c._))})(this,function(c,t,O,F){"use strict";function T(e,
|
|
1
|
+
(function(c,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("echarts/core"),require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","vue-demi","echarts/core","lodash-es"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.IduxChartsCore={},c.VueDemi,c.echarts,c._))})(this,function(c,t,O,F){"use strict";function T(e,s,n){let r;t.watch([e,s,n],([o,l,f],h,p)=>{!o||!l||(f?(r??(r=O.throttle(()=>l.resize(),16)),y(o,r)):g(o,r),p(()=>g(o,r)))})}const d=new Map;function y(e,s,n){if(!(!e||!s))if(d.has(e))d.get(e).listeners.push(s);else{const r=[s],o=new ResizeObserver(l=>{l.forEach(f=>r.forEach(h=>h(f)))});o.observe(e,n),d.set(e,{listeners:r,ro:o})}}function g(e,s){if(!e||!s||!d.has(e))return;const{listeners:n,ro:r}=d.get(e),o=n.indexOf(s);o>-1&&(n.splice(o,1),n.length===0&&(r.disconnect(),d.delete(e)))}function R(e){const s=t.shallowRef(),n=t.shallowRef(),r=t.shallowRef(),o=t.computed(()=>e.value.autoResize??!0),l=t.computed(()=>e.value.group),f=t.computed(()=>e.value.initOption),h=t.computed(()=>e.value.loading),p=t.computed(()=>e.value.setOptionOpts),z=t.computed(()=>e.value.theme),b=()=>{const a=s.value;if(!a)return;const i=O.init(a,z.value,f.value),u=e.value,{restOptions:S,events:q}=v(u,!1);i.setOption(S,p.value),r.value=F.cloneDeep(S),q.forEach(([x,A,H])=>{let C=A;H&&(C=(...M)=>{A(...M),i.off(x,C)}),i.on(x,C)}),u.onReady&&u.onReady(i),n.value=i},w=()=>{n.value&&(n.value.dispose(),n.value=void 0)};return t.onMounted(()=>b()),t.onBeforeUnmount(()=>w()),t.watch(e,a=>{const i=n.value;if(!i)return;const{restOptions:u}=v(a);F.isEqual(u,r.value)||(i.setOption(u,p.value),r.value=F.cloneDeep(u))},{deep:!0}),t.watch([z,f],()=>{w(),b()},{deep:!0}),t.watchEffect(()=>{const a=l.value;a&&n.value&&(n.value.group=a)}),t.watchEffect(()=>{const a=n.value;if(!a)return;const i=h.value;i?a.showLoading(F.isObject(i)?i:void 0):a.hideLoading()}),T(s,n,o),{containerRef:s,chartRef:n}}function B(e){return/^on[^a-z]/.test(e)}const I=["class","style","autoResize","group","loading","setOptionOpts","theme","onReady"];function v(e,s=!0){const n={},r=[];return Object.keys(e).forEach(o=>{if(!I.includes(o)){if(B(o)){if(s)return;const l=e[o];if(l){const f=o.endsWith("Once"),h=f?o.length-4:void 0,p=o.charAt(2).toLowerCase()+o.substring(3,h);r.push([p,l,f])}return}n[o]=e[o]}}),{restOptions:n,events:r}}const E=Symbol("CHART_TOKEN"),_={theme:"seer"},j=t.defineComponent({name:"IxChart",inheritAttrs:!1,setup(e,{attrs:s}){const n=t.inject(E,_),r=t.computed(()=>({...n,...s})),{containerRef:o}=R(r);return{containerRef:o,mergedProps:r}},render(){const{class:e,style:s}=this.mergedProps,n=t.isVue2?{ref:"containerRef",attrs:{class:e,style:s}}:{ref:"containerRef",class:e,style:s};return t.h("div",n)}}),m=["#458FFF","#45D9A3","#FFC145","#F5654F","#6A6AFD","#6ED1FF","#008787","#FF9245","#F587B3","#8352CC"],L=["#458FFF","#C8DEFF","#45D9A3","#C8F4E4","#FFC145","#FFEDC8","#F5654F","#FCD1CB","#6A6AFD","#D3D3FE","#6ED1FF","#D3D3FE","#008787","#B3DBDB","#FF9245","#FFDFC8","#F587B3","#FCDBE8","#8352CC","#FCDBE8"],P={color:m,textStyle:{color:"#2F3540",fontSize:"12px"},pie:{avoidLabelOverlap:!1,center:["25%","50%"],itemStyle:{borderWidth:1,borderColor:"#fff"},label:{show:!1,formatter:"{c}",position:"inside"}},legend:{textStyle:{color:"#2F3540",fontSize:"12px"}},title:{itemGap:4,textStyle:{color:"#2F3540",fontSize:"30px"},subtextStyle:{color:"#6F7785",fontSize:"12px"}},tooltip:{borderWidth:0,padding:12}};c.CHART_TOKEN=E,c.IxChart=j,c.seerColors10=m,c.seerColors20=L,c.seerTheme=P,c.useChart=R,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idux/charts-core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A UI Component Development Kit for Vue 3.x",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -29,10 +29,6 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"/dist"
|
|
31
31
|
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"clean": "rimraf dist node_modules",
|
|
34
|
-
"build": "rimraf dist && vite build"
|
|
35
|
-
},
|
|
36
32
|
"dependencies": {
|
|
37
33
|
"echarts": "^5.4.0",
|
|
38
34
|
"lodash-es": "^4.17.0",
|
|
@@ -46,5 +42,9 @@
|
|
|
46
42
|
"@vue/composition-api": {
|
|
47
43
|
"optional": true
|
|
48
44
|
}
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"clean": "rimraf dist node_modules",
|
|
48
|
+
"build": "rimraf dist && vite build"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|