@idux/charts-core 0.1.0 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @idux/charts-core
2
+
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0d08aec: update vite config
@@ -1,9 +1,4 @@
1
- import { type HTMLAttributes, type InjectionKey } from 'vue-demi';
2
- import { type ChartOption, type AdditionalChartOption } from '../types';
3
- export interface ChartProps extends ChartOption, AdditionalChartOption {
4
- }
5
- export declare const CHART_TOKEN: InjectionKey<ChartProps>;
6
- export declare const defaultChartProps: ChartProps;
7
- type IChartProps = Omit<HTMLAttributes, keyof ChartProps> & ChartProps;
8
- declare const _default: import("vue-demi").DefineComponent<IChartProps, {}, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<IChartProps>>, {}>;
1
+ import { type HTMLAttributes } from 'vue-demi';
2
+ import { type ChartProps } from '../types';
3
+ declare const _default: import("vue-demi").DefineComponent<Omit<HTMLAttributes, keyof ChartProps> & ChartProps, {}, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<Omit<HTMLAttributes, keyof ChartProps> & ChartProps>>, {}>;
9
4
  export default _default;
@@ -1,3 +1,2 @@
1
- declare const IxChart: import("vue").DefineComponent<Omit<import("vue").HTMLAttributes, keyof import("./Chart").ChartProps> & import("./Chart").ChartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Omit<import("vue").HTMLAttributes, keyof import("./Chart").ChartProps> & import("./Chart").ChartProps>>, {}>;
1
+ declare const IxChart: import("vue").DefineComponent<Omit<import("vue").HTMLAttributes, keyof import("..").ChartProps> & import("..").ChartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Omit<import("vue").HTMLAttributes, keyof import("..").ChartProps> & import("..").ChartProps>>, {}>;
2
2
  export { IxChart };
3
- export { CHART_TOKEN, type ChartProps } from './Chart';
@@ -1,7 +1,8 @@
1
- import { type ComputedRef, type ShallowRef } from 'vue-demi';
1
+ import { type Ref, type ShallowRef } from 'vue-demi';
2
2
  import { type EChartsType } from 'echarts/core';
3
- import { type ChartProps } from '../components';
4
- export declare function useChart<U extends ChartProps>(options: ComputedRef<U>): {
3
+ import { type ChartProps } from '../types';
4
+ export type MaybeRef<T> = T | Ref<T>;
5
+ export declare function useChart<U extends ChartProps>(options: MaybeRef<U>): {
5
6
  containerRef: ShallowRef<HTMLDivElement | undefined>;
6
7
  chartRef: ShallowRef<EChartsType | undefined>;
7
8
  };
package/dist/index.js ADDED
@@ -0,0 +1,317 @@
1
+ import { DataZoomComponent as B, LegendComponent as T, GridComponent as W, TitleComponent as I, TooltipComponent as G } from "echarts/components";
2
+ import { LabelLayout as M, UniversalTransition as j } from "echarts/features";
3
+ import { SVGRenderer as V } from "echarts/renderers";
4
+ import { watch as g, shallowRef as m, computed as p, unref as c, onMounted as H, onBeforeUnmount as N, watchEffect as b, isVue2 as P, defineComponent as U, h as Z } from "vue-demi";
5
+ import { throttle as _, init as q, use as $, registerTheme as J } from "echarts/core";
6
+ import { isEqual as K, cloneDeep as A, isObject as Q, isNil as X } from "lodash-es";
7
+ function Y(e, o, t) {
8
+ let r;
9
+ g(
10
+ [e, o, t],
11
+ ([n, a, l], f, d) => {
12
+ !n || !a || (l ? (r ?? (r = _(() => a.resize(), 16)), k(n, r)) : y(n, r), d(() => y(n, r)));
13
+ }
14
+ );
15
+ }
16
+ const F = /* @__PURE__ */ new Map();
17
+ function k(e, o, t) {
18
+ if (!(!e || !o))
19
+ if (F.has(e))
20
+ F.get(e).listeners.push(o);
21
+ else {
22
+ const r = [o], n = new ResizeObserver((a) => {
23
+ a.forEach((l) => r.forEach((f) => f(l)));
24
+ });
25
+ n.observe(e, t), F.set(e, { listeners: r, ro: n });
26
+ }
27
+ }
28
+ function y(e, o) {
29
+ if (!e || !o || !F.has(e))
30
+ return;
31
+ const { listeners: t, ro: r } = F.get(e), n = t.indexOf(o);
32
+ n > -1 && (t.splice(n, 1), t.length === 0 && (r.disconnect(), F.delete(e)));
33
+ }
34
+ function ee(e) {
35
+ const o = m(), t = m(), r = m(), n = p(() => c(e).autoResize ?? !0), a = p(() => c(e).group), l = p(() => c(e).initOption), f = p(() => c(e).loading), d = p(() => c(e).setOptionOpts), v = p(() => c(e).theme ?? "seer"), x = () => {
36
+ const i = o.value;
37
+ if (!i)
38
+ return;
39
+ const s = q(i, v.value, l.value), u = c(e), { restOptions: O, events: w } = R(u, !1);
40
+ s.setOption(O, d.value), r.value = A(O), w.forEach(([D, E, z]) => {
41
+ let h = E;
42
+ z && (h = (...L) => {
43
+ E(...L), s.off(D, h);
44
+ }), s.on(D, h);
45
+ }), u.onReady && u.onReady(s), t.value = s;
46
+ }, C = () => {
47
+ t.value && (t.value.dispose(), t.value = void 0);
48
+ };
49
+ return H(() => x()), N(() => C()), g(
50
+ () => c(e),
51
+ (i) => {
52
+ const s = t.value;
53
+ if (!s)
54
+ return;
55
+ const { restOptions: u } = R(i);
56
+ K(u, r.value) || (s.setOption(u, d.value), r.value = A(u));
57
+ },
58
+ {
59
+ deep: !0
60
+ }
61
+ ), g([v, l], () => {
62
+ C(), x();
63
+ }), b(() => {
64
+ const i = a.value;
65
+ i && t.value && (t.value.group = i);
66
+ }), b(() => {
67
+ const i = t.value;
68
+ if (!i)
69
+ return;
70
+ const s = f.value;
71
+ s ? i.showLoading(Q(s) ? s : void 0) : i.hideLoading();
72
+ }), Y(o, t, n), { containerRef: o, chartRef: t };
73
+ }
74
+ function te(e) {
75
+ return /^on[^a-z]/.test(e);
76
+ }
77
+ const oe = [
78
+ "class",
79
+ "style",
80
+ "autoResize",
81
+ "group",
82
+ "loading",
83
+ "setOptionOpts",
84
+ "theme",
85
+ "onReady"
86
+ ];
87
+ function R(e, o = !0) {
88
+ const t = {}, r = [];
89
+ return Object.keys(e).forEach((n) => {
90
+ if (!oe.includes(n)) {
91
+ if (te(n)) {
92
+ if (o)
93
+ return;
94
+ const a = e[n];
95
+ if (a) {
96
+ const l = n.endsWith("Once"), f = l ? n.length - 4 : void 0, d = n.charAt(2).toLowerCase() + n.substring(3, f);
97
+ r.push([d, a, l]);
98
+ }
99
+ return;
100
+ }
101
+ t[n] = e[n];
102
+ }
103
+ }), { restOptions: t, events: r };
104
+ }
105
+ const ne = [
106
+ "#458FFF",
107
+ "#45D9A3",
108
+ "#FFC145",
109
+ "#F5654F",
110
+ "#6A6AFD",
111
+ "#6ED1FF",
112
+ "#008787",
113
+ "#FF9245",
114
+ "#F587B3",
115
+ "#8352CC",
116
+ "#65779B"
117
+ ], pe = [
118
+ "#458FFF",
119
+ "#C8DEFF",
120
+ "#45D9A3",
121
+ "#C8F4E4",
122
+ "#FFC145",
123
+ "#FFEDC8",
124
+ "#F5654F",
125
+ "#FCD1CB",
126
+ "#6A6AFD",
127
+ "#D3D3FE",
128
+ "#6ED1FF",
129
+ "#D3D3FE",
130
+ "#008787",
131
+ "#B3DBDB",
132
+ "#FF9245",
133
+ "#FFDFC8",
134
+ "#F587B3",
135
+ "#FCDBE8",
136
+ "#8352CC",
137
+ "#FCDBE8",
138
+ "#65779B",
139
+ "#65779B"
140
+ ], re = {
141
+ color: ne,
142
+ textStyle: {
143
+ color: "#2F3540",
144
+ fontSize: "12px"
145
+ },
146
+ bar: {
147
+ barGap: 0.2,
148
+ barWidth: 10,
149
+ label: {
150
+ color: "#6F7785",
151
+ position: "top"
152
+ }
153
+ },
154
+ line: {
155
+ label: {
156
+ color: "#6F7785",
157
+ position: "top"
158
+ }
159
+ },
160
+ pie: {
161
+ avoidLabelOverlap: !1,
162
+ center: ["25%", "50%"],
163
+ radius: ["70%", "80%"],
164
+ itemStyle: {
165
+ borderWidth: 1,
166
+ borderColor: "#fff"
167
+ },
168
+ label: {
169
+ show: !1,
170
+ color: "#2F3540",
171
+ formatter: "{c}",
172
+ position: "inside"
173
+ }
174
+ },
175
+ legend: {
176
+ itemWidth: 12,
177
+ itemHeight: 12,
178
+ textStyle: {
179
+ color: "#2F3540",
180
+ fontSize: "12px"
181
+ }
182
+ },
183
+ title: {
184
+ itemGap: 4,
185
+ textStyle: {
186
+ color: "#2F3540",
187
+ fontSize: "14px",
188
+ fontWeight: 500
189
+ },
190
+ subtextStyle: {
191
+ color: "#6F7785",
192
+ fontSize: "12px"
193
+ }
194
+ },
195
+ tooltip: {
196
+ borderWidth: 0,
197
+ padding: 12,
198
+ textStyle: {
199
+ color: "#2F3540"
200
+ },
201
+ axisPointer: {
202
+ z: -100,
203
+ lineStyle: {
204
+ type: "solid",
205
+ color: "#E1E5EB"
206
+ }
207
+ }
208
+ },
209
+ categoryAxis: {
210
+ axisLine: {
211
+ show: !0,
212
+ lineStyle: {
213
+ color: "#EDF1F7"
214
+ }
215
+ },
216
+ axisTick: {
217
+ show: !0,
218
+ alignWithLabel: !0,
219
+ lineStyle: {
220
+ color: "#EDF1F7"
221
+ }
222
+ },
223
+ axisLabel: {
224
+ color: "#6F7785"
225
+ },
226
+ splitLine: {
227
+ show: !1
228
+ },
229
+ splitArea: {
230
+ show: !1
231
+ }
232
+ },
233
+ valueAxis: {
234
+ axisLine: {
235
+ show: !1
236
+ },
237
+ axisTick: {
238
+ show: !1
239
+ },
240
+ axisLabel: {
241
+ color: "#6F7785"
242
+ },
243
+ splitLine: {
244
+ lineStyle: {
245
+ color: "#EDF1F7"
246
+ }
247
+ },
248
+ splitArea: {
249
+ show: !1
250
+ },
251
+ nameTextStyle: {
252
+ color: "#6F7785",
253
+ padding: [0, 30, -4, 0]
254
+ }
255
+ },
256
+ dataZoom: {
257
+ height: 20
258
+ }
259
+ };
260
+ function Fe(e) {
261
+ return !!(e && e.xAxis && e.xAxis.data);
262
+ }
263
+ function se(e, o) {
264
+ const t = {
265
+ ...e,
266
+ ...o
267
+ };
268
+ return P ? { attrs: t } : t;
269
+ }
270
+ function he(e) {
271
+ return Object.entries(e).reduce((o, [t, r]) => (r !== void 0 && (o[t] = r), o), {});
272
+ }
273
+ function me(e) {
274
+ return X(e) ? [] : Array.isArray(e) ? e : [e];
275
+ }
276
+ function ie(e, o) {
277
+ $(o), J("seer", re);
278
+ const t = (r) => {
279
+ r.component(e.name, e);
280
+ };
281
+ e.install = t;
282
+ }
283
+ const S = U({
284
+ name: "IxChart",
285
+ inheritAttrs: !1,
286
+ setup(e, { attrs: o }) {
287
+ const { containerRef: t } = ee(o);
288
+ return { containerRef: t };
289
+ },
290
+ render() {
291
+ const { class: e, style: o } = this.$attrs, t = se({ class: e, style: o });
292
+ return Z("div", { ref: "containerRef", ...t });
293
+ }
294
+ });
295
+ ie(S, [
296
+ B,
297
+ T,
298
+ W,
299
+ I,
300
+ G,
301
+ M,
302
+ j,
303
+ V
304
+ ]);
305
+ const ge = S;
306
+ export {
307
+ ge as IxChart,
308
+ me as convertArray,
309
+ ie as createInstall,
310
+ he as filterEmptyProps,
311
+ Fe as isVertical,
312
+ se as mergeAttrs,
313
+ ne as seerColors,
314
+ pe as seerColorsMore,
315
+ re as seerTheme,
316
+ ee as useChart
317
+ };
@@ -0,0 +1 @@
1
+ (function(o,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("echarts/components"),require("echarts/features"),require("echarts/renderers"),require("vue-demi"),require("echarts/core"),require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","echarts/components","echarts/features","echarts/renderers","vue-demi","echarts/core","lodash-es"],l):(o=typeof globalThis<"u"?globalThis:o||self,l(o.IduxChartsCore={},o.echarts,o.echarts,o.echarts,o.VueDemi,o.echarts,o._))})(this,function(o,l,x,q,r,g,C){"use strict";function W(e,n,t){let i;r.watch([e,n,t],([s,f,u],p,F)=>{!s||!f||(u?(i??(i=g.throttle(()=>f.resize(),16)),M(s,i)):y(s,i),F(()=>y(s,i)))})}const h=new Map;function M(e,n,t){if(!(!e||!n))if(h.has(e))h.get(e).listeners.push(n);else{const i=[n],s=new ResizeObserver(f=>{f.forEach(u=>i.forEach(p=>p(u)))});s.observe(e,t),h.set(e,{listeners:i,ro:s})}}function y(e,n){if(!e||!n||!h.has(e))return;const{listeners:t,ro:i}=h.get(e),s=t.indexOf(n);s>-1&&(t.splice(s,1),t.length===0&&(i.disconnect(),h.delete(e)))}function A(e){const n=r.shallowRef(),t=r.shallowRef(),i=r.shallowRef(),s=r.computed(()=>r.unref(e).autoResize??!0),f=r.computed(()=>r.unref(e).group),u=r.computed(()=>r.unref(e).initOption),p=r.computed(()=>r.unref(e).loading),F=r.computed(()=>r.unref(e).setOptionOpts),z=r.computed(()=>r.unref(e).theme??"seer"),L=()=>{const c=n.value;if(!c)return;const a=g.init(c,z.value,u.value),d=r.unref(e),{restOptions:T,events:U}=m(d,!1);a.setOption(T,F.value),i.value=C.cloneDeep(T),U.forEach(([v,I,Z])=>{let O=I;Z&&(O=(...$)=>{I(...$),a.off(v,O)}),a.on(v,O)}),d.onReady&&d.onReady(a),t.value=a},B=()=>{t.value&&(t.value.dispose(),t.value=void 0)};return r.onMounted(()=>L()),r.onBeforeUnmount(()=>B()),r.watch(()=>r.unref(e),c=>{const a=t.value;if(!a)return;const{restOptions:d}=m(c);C.isEqual(d,i.value)||(a.setOption(d,F.value),i.value=C.cloneDeep(d))},{deep:!0}),r.watch([z,u],()=>{B(),L()}),r.watchEffect(()=>{const c=f.value;c&&t.value&&(t.value.group=c)}),r.watchEffect(()=>{const c=t.value;if(!c)return;const a=p.value;a?c.showLoading(C.isObject(a)?a:void 0):c.hideLoading()}),W(n,t,s),{containerRef:n,chartRef:t}}function j(e){return/^on[^a-z]/.test(e)}const G=["class","style","autoResize","group","loading","setOptionOpts","theme","onReady"];function m(e,n=!0){const t={},i=[];return Object.keys(e).forEach(s=>{if(!G.includes(s)){if(j(s)){if(n)return;const f=e[s];if(f){const u=s.endsWith("Once"),p=u?s.length-4:void 0,F=s.charAt(2).toLowerCase()+s.substring(3,p);i.push([F,f,u])}return}t[s]=e[s]}}),{restOptions:t,events:i}}const E=["#458FFF","#45D9A3","#FFC145","#F5654F","#6A6AFD","#6ED1FF","#008787","#FF9245","#F587B3","#8352CC","#65779B"],V=["#458FFF","#C8DEFF","#45D9A3","#C8F4E4","#FFC145","#FFEDC8","#F5654F","#FCD1CB","#6A6AFD","#D3D3FE","#6ED1FF","#D3D3FE","#008787","#B3DBDB","#FF9245","#FFDFC8","#F587B3","#FCDBE8","#8352CC","#FCDBE8","#65779B","#65779B"],w={color:E,textStyle:{color:"#2F3540",fontSize:"12px"},bar:{barGap:.2,barWidth:10,label:{color:"#6F7785",position:"top"}},line:{label:{color:"#6F7785",position:"top"}},pie:{avoidLabelOverlap:!1,center:["25%","50%"],radius:["70%","80%"],itemStyle:{borderWidth:1,borderColor:"#fff"},label:{show:!1,color:"#2F3540",formatter:"{c}",position:"inside"}},legend:{itemWidth:12,itemHeight:12,textStyle:{color:"#2F3540",fontSize:"12px"}},title:{itemGap:4,textStyle:{color:"#2F3540",fontSize:"14px",fontWeight:500},subtextStyle:{color:"#6F7785",fontSize:"12px"}},tooltip:{borderWidth:0,padding:12,textStyle:{color:"#2F3540"},axisPointer:{z:-100,lineStyle:{type:"solid",color:"#E1E5EB"}}},categoryAxis:{axisLine:{show:!0,lineStyle:{color:"#EDF1F7"}},axisTick:{show:!0,alignWithLabel:!0,lineStyle:{color:"#EDF1F7"}},axisLabel:{color:"#6F7785"},splitLine:{show:!1},splitArea:{show:!1}},valueAxis:{axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:"#6F7785"},splitLine:{lineStyle:{color:"#EDF1F7"}},splitArea:{show:!1},nameTextStyle:{color:"#6F7785",padding:[0,30,-4,0]}},dataZoom:{height:20}};function P(e){return!!(e&&e.xAxis&&e.xAxis.data)}function b(e,n){const t={...e,...n};return r.isVue2?{attrs:t}:t}function _(e){return Object.entries(e).reduce((n,[t,i])=>(i!==void 0&&(n[t]=i),n),{})}function H(e){return C.isNil(e)?[]:Array.isArray(e)?e:[e]}function R(e,n){g.use(n),g.registerTheme("seer",w);const t=i=>{i.component(e.name,e)};e.install=t}const S=r.defineComponent({name:"IxChart",inheritAttrs:!1,setup(e,{attrs:n}){const{containerRef:t}=A(n);return{containerRef:t}},render(){const{class:e,style:n}=this.$attrs,t=b({class:e,style:n});return r.h("div",{ref:"containerRef",...t})}});R(S,[l.DataZoomComponent,l.LegendComponent,l.GridComponent,l.TitleComponent,l.TooltipComponent,x.LabelLayout,x.UniversalTransition,q.SVGRenderer]);const N=S;o.IxChart=N,o.convertArray=H,o.createInstall=R,o.filterEmptyProps=_,o.isVertical=P,o.mergeAttrs=b,o.seerColors=E,o.seerColorsMore=V,o.seerTheme=w,o.useChart=A,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
@@ -1,25 +1,43 @@
1
- export declare const seerColors10: string[];
2
- export declare const seerColors20: string[];
1
+ export declare const seerColors: string[];
2
+ export declare const seerColorsMore: string[];
3
3
  export declare const seerTheme: {
4
4
  color: string[];
5
5
  textStyle: {
6
6
  color: string;
7
7
  fontSize: string;
8
8
  };
9
+ bar: {
10
+ barGap: number;
11
+ barWidth: number;
12
+ label: {
13
+ color: string;
14
+ position: string;
15
+ };
16
+ };
17
+ line: {
18
+ label: {
19
+ color: string;
20
+ position: string;
21
+ };
22
+ };
9
23
  pie: {
10
24
  avoidLabelOverlap: boolean;
11
25
  center: string[];
26
+ radius: string[];
12
27
  itemStyle: {
13
28
  borderWidth: number;
14
29
  borderColor: string;
15
30
  };
16
31
  label: {
17
32
  show: boolean;
33
+ color: string;
18
34
  formatter: string;
19
35
  position: string;
20
36
  };
21
37
  };
22
38
  legend: {
39
+ itemWidth: number;
40
+ itemHeight: number;
23
41
  textStyle: {
24
42
  color: string;
25
43
  fontSize: string;
@@ -30,6 +48,7 @@ export declare const seerTheme: {
30
48
  textStyle: {
31
49
  color: string;
32
50
  fontSize: string;
51
+ fontWeight: number;
33
52
  };
34
53
  subtextStyle: {
35
54
  color: string;
@@ -39,5 +58,65 @@ export declare const seerTheme: {
39
58
  tooltip: {
40
59
  borderWidth: number;
41
60
  padding: number;
61
+ textStyle: {
62
+ color: string;
63
+ };
64
+ axisPointer: {
65
+ z: number;
66
+ lineStyle: {
67
+ type: string;
68
+ color: string;
69
+ };
70
+ };
71
+ };
72
+ categoryAxis: {
73
+ axisLine: {
74
+ show: boolean;
75
+ lineStyle: {
76
+ color: string;
77
+ };
78
+ };
79
+ axisTick: {
80
+ show: boolean;
81
+ alignWithLabel: boolean;
82
+ lineStyle: {
83
+ color: string;
84
+ };
85
+ };
86
+ axisLabel: {
87
+ color: string;
88
+ };
89
+ splitLine: {
90
+ show: boolean;
91
+ };
92
+ splitArea: {
93
+ show: boolean;
94
+ };
95
+ };
96
+ valueAxis: {
97
+ axisLine: {
98
+ show: boolean;
99
+ };
100
+ axisTick: {
101
+ show: boolean;
102
+ };
103
+ axisLabel: {
104
+ color: string;
105
+ };
106
+ splitLine: {
107
+ lineStyle: {
108
+ color: string;
109
+ };
110
+ };
111
+ splitArea: {
112
+ show: boolean;
113
+ };
114
+ nameTextStyle: {
115
+ color: string;
116
+ padding: number[];
117
+ };
118
+ };
119
+ dataZoom: {
120
+ height: number;
42
121
  };
43
122
  };
@@ -1,5 +1,5 @@
1
1
  import type { BarSeriesOption, LineSeriesOption, PieSeriesOption } from 'echarts/charts';
2
- import type { LegendComponentOption, TitleComponentOption, TooltipComponentOption } from 'echarts/components';
2
+ import type { DatasetComponentOption, DataZoomComponentOption, GridComponentOption, LegendComponentOption, TitleComponentOption, TooltipComponentOption } from 'echarts/components';
3
3
  import type { ComposeOption, EChartsType, init, SetOptionOpts } from 'echarts/core';
4
4
  export type ChartInitParameters = Parameters<typeof init>;
5
5
  export type ChartTheme = NonNullable<ChartInitParameters[1]>;
@@ -43,6 +43,8 @@ interface ComponentOption {
43
43
  z?: number;
44
44
  zlevel?: number;
45
45
  }
46
- export type BaseChartOption<T extends ComponentOption> = ComposeOption<LegendComponentOption | TitleComponentOption | TooltipComponentOption | T>;
47
- export type ChartOption = ComposeOption<BarSeriesOption | PieSeriesOption | LineSeriesOption | LegendComponentOption | TitleComponentOption | TooltipComponentOption>;
46
+ export type BaseChartOption<T extends ComponentOption> = ComposeOption<DatasetComponentOption | DataZoomComponentOption | GridComponentOption | LegendComponentOption | TitleComponentOption | TooltipComponentOption | T>;
47
+ export type ChartOption = ComposeOption<DatasetComponentOption | DataZoomComponentOption | GridComponentOption | LegendComponentOption | TitleComponentOption | TooltipComponentOption | BarSeriesOption | PieSeriesOption | LineSeriesOption>;
48
+ export interface ChartProps extends ChartOption, AdditionalChartOption {
49
+ }
48
50
  export {};
@@ -1,3 +1,10 @@
1
+ import { use } from 'echarts/core';
1
2
  export type Writeable<T> = {
2
3
  -readonly [P in keyof T]: T[P];
3
4
  };
5
+ export declare function isVertical(option: any): boolean;
6
+ export declare function mergeAttrs(props: any, attrs?: any): any;
7
+ export declare function filterEmptyProps<T extends object>(props: T): T;
8
+ export declare function convertArray<T>(value: T | undefined | null | Array<T | undefined | null>): T[];
9
+ export declare function convertArray<T>(value: T | readonly T[]): readonly T[];
10
+ export declare function createInstall(Chart: any, ext: Parameters<typeof use>[0]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idux/charts-core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "A UI Component Development Kit for Vue 3.x",
5
5
  "keywords": [
6
6
  "vue",
@@ -20,15 +20,18 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "IDuxFE<idux.feteam@gmail.com>",
23
- "main": "./dist/index.mjs",
24
- "module": "./dist/index.mjs",
23
+ "type": "module",
24
+ "main": "./dist/index.umd.cjs",
25
+ "module": "./dist/index.js",
25
26
  "typings": "./dist/index.d.ts",
26
- "unpkg": "./dist/index.umd.js",
27
- "jsdelivr": "./dist/index.umd.js",
28
- "sideEffects": false,
27
+ "unpkg": "./dist/index.umd.cjs",
28
+ "jsdelivr": "./dist/index.umd.cjs",
29
29
  "files": [
30
- "/dist"
30
+ "dist",
31
+ "*.md",
32
+ "*.d.ts"
31
33
  ],
34
+ "sideEffects": false,
32
35
  "dependencies": {
33
36
  "echarts": "^5.4.0",
34
37
  "lodash-es": "^4.17.0",
package/dist/index.mjs DELETED
@@ -1,201 +0,0 @@
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
- h(
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
- }
11
- );
12
- }
13
- const p = /* @__PURE__ */ new Map();
14
- function W(e, o, t) {
15
- if (!(!e || !o))
16
- if (p.has(e))
17
- p.get(e).listeners.push(o);
18
- else {
19
- const s = [o], n = new ResizeObserver((c) => {
20
- c.forEach((a) => s.forEach((f) => f(a)));
21
- });
22
- n.observe(e, t), p.set(e, { listeners: s, ro: n });
23
- }
24
- }
25
- function z(e, o) {
26
- if (!e || !o || !p.has(e))
27
- return;
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
- }
31
- function G(e) {
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
- return;
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
- let F = R;
39
- S && (F = (...B) => {
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
- };
46
- return w(() => C()), T(() => g()), h(
47
- e,
48
- (i) => {
49
- const r = t.value;
50
- if (!r)
51
- return;
52
- const { restOptions: u } = b(i);
53
- H(u, s.value) || (r.setOption(u, d.value), s.value = x(u));
54
- },
55
- {
56
- deep: !0
57
- }
58
- ), h(
59
- [m, a],
60
- () => {
61
- g(), C();
62
- },
63
- {
64
- deep: !0
65
- }
66
- ), E(() => {
67
- const i = c.value;
68
- i && t.value && (t.value.group = i);
69
- }), E(() => {
70
- const i = t.value;
71
- if (!i)
72
- return;
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
- }
77
- function K(e) {
78
- return /^on[^a-z]/.test(e);
79
- }
80
- const q = [
81
- "class",
82
- "style",
83
- "autoResize",
84
- "group",
85
- "loading",
86
- "setOptionOpts",
87
- "theme",
88
- "onReady"
89
- ];
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
- return;
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
- }
102
- return;
103
- }
104
- t[n] = e[n];
105
- }
106
- }), { restOptions: t, events: s };
107
- }
108
- const U = Symbol("CHART_TOKEN"), V = {
109
- theme: "seer"
110
- }, J = y({
111
- name: "IxChart",
112
- inheritAttrs: !1,
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 });
120
- }
121
- }), $ = J, Q = [
122
- "#458FFF",
123
- "#45D9A3",
124
- "#FFC145",
125
- "#F5654F",
126
- "#6A6AFD",
127
- "#6ED1FF",
128
- "#008787",
129
- "#FF9245",
130
- "#F587B3",
131
- "#8352CC"
132
- ], k = [
133
- "#458FFF",
134
- "#C8DEFF",
135
- "#45D9A3",
136
- "#C8F4E4",
137
- "#FFC145",
138
- "#FFEDC8",
139
- "#F5654F",
140
- "#FCD1CB",
141
- "#6A6AFD",
142
- "#D3D3FE",
143
- "#6ED1FF",
144
- "#D3D3FE",
145
- "#008787",
146
- "#B3DBDB",
147
- "#FF9245",
148
- "#FFDFC8",
149
- "#F587B3",
150
- "#FCDBE8",
151
- "#8352CC",
152
- "#FCDBE8"
153
- ], ee = {
154
- color: Q,
155
- textStyle: {
156
- color: "#2F3540",
157
- fontSize: "12px"
158
- },
159
- pie: {
160
- avoidLabelOverlap: !1,
161
- center: ["25%", "50%"],
162
- itemStyle: {
163
- borderWidth: 1,
164
- borderColor: "#fff"
165
- },
166
- label: {
167
- show: !1,
168
- formatter: "{c}",
169
- position: "inside"
170
- }
171
- },
172
- legend: {
173
- textStyle: {
174
- color: "#2F3540",
175
- fontSize: "12px"
176
- }
177
- },
178
- title: {
179
- itemGap: 4,
180
- textStyle: {
181
- color: "#2F3540",
182
- fontSize: "30px"
183
- },
184
- subtextStyle: {
185
- color: "#6F7785",
186
- fontSize: "12px"
187
- }
188
- },
189
- tooltip: {
190
- borderWidth: 0,
191
- padding: 12
192
- }
193
- };
194
- export {
195
- U as CHART_TOKEN,
196
- $ as IxChart,
197
- Q as seerColors10,
198
- k as seerColors20,
199
- ee as seerTheme,
200
- G as useChart
201
- };
package/dist/index.umd.js DELETED
@@ -1 +0,0 @@
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"})});