@idux/charts-core 0.1.0 → 0.4.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,13 @@
1
+ # @idux/charts-core
2
+
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - docs(release): publish v0.4.0
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 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,333 @@
1
+ import { DataZoomComponent as T, LegendComponent as W, GridComponent as I, TitleComponent as G, TooltipComponent as M } from "echarts/components";
2
+ import { LabelLayout as V, UniversalTransition as j } from "echarts/features";
3
+ import { SVGRenderer as H } from "echarts/renderers";
4
+ import { watch as g, shallowRef as m, computed as d, unref as c, onMounted as N, onBeforeUnmount as P, watchEffect as A, isVue2 as U, defineComponent as Z, normalizeStyle as _, h as q } from "vue-demi";
5
+ import { throttle as $, init as J, use as K, registerTheme as Q } from "echarts/core";
6
+ import { isEqual as X, cloneDeep as b, isBoolean as Y, isNil as k } from "lodash-es";
7
+ function ee(e, o, t) {
8
+ let r;
9
+ g(
10
+ [e, o, t],
11
+ ([n, a, l], f, F) => {
12
+ !n || !a || (l ? (r ?? (r = $(() => a.resize(), 16)), te(n, r)) : y(n, r), F(() => y(n, r)));
13
+ }
14
+ );
15
+ }
16
+ const p = /* @__PURE__ */ new Map();
17
+ function te(e, o, t) {
18
+ if (!(!e || !o))
19
+ if (p.has(e))
20
+ p.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), p.set(e, { listeners: r, ro: n });
26
+ }
27
+ }
28
+ function y(e, o) {
29
+ if (!e || !o || !p.has(e))
30
+ return;
31
+ const { listeners: t, ro: r } = p.get(e), n = t.indexOf(o);
32
+ n > -1 && (t.splice(n, 1), t.length === 0 && (r.disconnect(), p.delete(e)));
33
+ }
34
+ const R = { text: "加载中..." };
35
+ function oe(e) {
36
+ const o = m(), t = m(), r = m(), n = d(() => c(e).autoResize ?? !0), a = d(() => c(e).group), l = d(() => c(e).initOption), f = d(() => c(e).loading), F = d(() => c(e).setOptionOpts), C = d(() => c(e).theme ?? "seer"), v = () => {
37
+ const i = o.value;
38
+ if (!i)
39
+ return;
40
+ const s = J(i, C.value, l.value), u = c(e), { restOptions: D, events: z } = S(u, !1);
41
+ s.setOption(D, F.value), r.value = b(D), z.forEach(([O, E, L]) => {
42
+ let h = E;
43
+ L && (h = (...B) => {
44
+ E(...B), s.off(O, h);
45
+ }), s.on(O, h);
46
+ }), u.onReady && u.onReady(s), t.value = s;
47
+ }, x = () => {
48
+ t.value && (t.value.dispose(), t.value = void 0);
49
+ };
50
+ return N(() => v()), P(() => x()), g(
51
+ () => c(e),
52
+ (i) => {
53
+ const s = t.value;
54
+ if (!s)
55
+ return;
56
+ const { restOptions: u } = S(i);
57
+ X(u, r.value) || (s.setOption(u, F.value), r.value = b(u));
58
+ },
59
+ {
60
+ deep: !0
61
+ }
62
+ ), g([C, l], () => {
63
+ x(), v();
64
+ }), A(() => {
65
+ const i = a.value;
66
+ i && t.value && (t.value.group = i);
67
+ }), A(() => {
68
+ const i = t.value;
69
+ if (!i)
70
+ return;
71
+ const s = f.value;
72
+ s ? i.showLoading(Y(s) ? R : { ...R, ...s }) : i.hideLoading();
73
+ }), ee(o, t, n), { containerRef: o, chartRef: t };
74
+ }
75
+ function ne(e) {
76
+ return /^on[^a-z]/.test(e);
77
+ }
78
+ const re = [
79
+ "class",
80
+ "style",
81
+ "autoResize",
82
+ "group",
83
+ "loading",
84
+ "setOptionOpts",
85
+ "theme",
86
+ "onReady"
87
+ ];
88
+ function S(e, o = !0) {
89
+ const t = {}, r = [];
90
+ return Object.keys(e).forEach((n) => {
91
+ if (!re.includes(n)) {
92
+ if (ne(n)) {
93
+ if (o)
94
+ return;
95
+ const a = e[n];
96
+ if (a) {
97
+ const l = n.endsWith("Once"), f = l ? n.length - 4 : void 0, F = n.charAt(2).toLowerCase() + n.substring(3, f);
98
+ r.push([F, a, l]);
99
+ }
100
+ return;
101
+ }
102
+ t[n] = e[n];
103
+ }
104
+ }), { restOptions: t, events: r };
105
+ }
106
+ const se = [
107
+ "#458FFF",
108
+ "#45D9A3",
109
+ "#FFC145",
110
+ "#F5654F",
111
+ "#6A6AFD",
112
+ "#6ED1FF",
113
+ "#008787",
114
+ "#FF9245",
115
+ "#F587B3",
116
+ "#8352CC",
117
+ "#65779B"
118
+ ], he = [
119
+ "#458FFF",
120
+ "#C8DEFF",
121
+ "#45D9A3",
122
+ "#C8F4E4",
123
+ "#FFC145",
124
+ "#FFEDC8",
125
+ "#F5654F",
126
+ "#FCD1CB",
127
+ "#6A6AFD",
128
+ "#D3D3FE",
129
+ "#6ED1FF",
130
+ "#D3D3FE",
131
+ "#008787",
132
+ "#B3DBDB",
133
+ "#FF9245",
134
+ "#FFDFC8",
135
+ "#F587B3",
136
+ "#FCDBE8",
137
+ "#8352CC",
138
+ "#FCDBE8",
139
+ "#65779B",
140
+ "#65779B"
141
+ ], me = [
142
+ "#8C1604",
143
+ "#DB4C35",
144
+ "#FF9245",
145
+ "#FFC145",
146
+ "#689FFF",
147
+ "#45D9A3",
148
+ "#99ACD1"
149
+ ], ie = {
150
+ color: se,
151
+ textStyle: {
152
+ color: "#2F3540",
153
+ fontSize: "12px"
154
+ },
155
+ bar: {
156
+ barGap: 0.2,
157
+ barWidth: 10,
158
+ label: {
159
+ color: "#6F7785",
160
+ position: "top"
161
+ }
162
+ },
163
+ line: {
164
+ label: {
165
+ color: "#6F7785",
166
+ position: "top"
167
+ }
168
+ },
169
+ pie: {
170
+ avoidLabelOverlap: !1,
171
+ radius: ["70%", "80%"],
172
+ itemStyle: {
173
+ borderWidth: 1,
174
+ borderColor: "#fff"
175
+ },
176
+ label: {
177
+ show: !1,
178
+ color: "#2F3540",
179
+ formatter: "{c}",
180
+ position: "inside"
181
+ }
182
+ },
183
+ legend: {
184
+ itemWidth: 12,
185
+ itemHeight: 12,
186
+ textStyle: {
187
+ color: "#6F7785",
188
+ fontSize: "12px"
189
+ }
190
+ },
191
+ title: {
192
+ itemGap: 4,
193
+ textStyle: {
194
+ color: "#2F3540",
195
+ fontSize: "12px",
196
+ fontWeight: 500
197
+ },
198
+ subtextStyle: {
199
+ color: "#6F7785",
200
+ fontSize: "12px"
201
+ }
202
+ },
203
+ tooltip: {
204
+ borderWidth: 0,
205
+ padding: 12,
206
+ textStyle: {
207
+ color: "#2F3540"
208
+ },
209
+ axisPointer: {
210
+ z: 1,
211
+ lineStyle: {
212
+ type: "solid",
213
+ color: "#E1E5EB"
214
+ }
215
+ }
216
+ },
217
+ categoryAxis: {
218
+ axisLine: {
219
+ show: !0,
220
+ lineStyle: {
221
+ color: "#EDF1F7"
222
+ }
223
+ },
224
+ axisTick: {
225
+ show: !0,
226
+ alignWithLabel: !0,
227
+ lineStyle: {
228
+ color: "#EDF1F7"
229
+ }
230
+ },
231
+ axisLabel: {
232
+ color: "#6F7785"
233
+ },
234
+ splitLine: {
235
+ show: !1
236
+ },
237
+ splitArea: {
238
+ show: !1
239
+ }
240
+ },
241
+ valueAxis: {
242
+ axisLine: {
243
+ show: !1
244
+ },
245
+ axisTick: {
246
+ show: !1
247
+ },
248
+ axisLabel: {
249
+ color: "#6F7785"
250
+ },
251
+ splitLine: {
252
+ lineStyle: {
253
+ color: "#EDF1F7"
254
+ }
255
+ },
256
+ splitArea: {
257
+ show: !1
258
+ },
259
+ nameTextStyle: {
260
+ color: "#6F7785",
261
+ padding: [0, 30, -4, 0]
262
+ }
263
+ },
264
+ dataZoom: {
265
+ height: 16
266
+ }
267
+ };
268
+ function ge(e) {
269
+ return !!(e && e.xAxis && e.xAxis.data);
270
+ }
271
+ function ae(e, o) {
272
+ const t = {
273
+ ...e,
274
+ ...o
275
+ };
276
+ return U ? { attrs: t } : t;
277
+ }
278
+ function Ce(e) {
279
+ return Object.entries(e).reduce((o, [t, r]) => (r !== void 0 && (o[t] = r), o), {});
280
+ }
281
+ function ve(e) {
282
+ return k(e) ? [] : Array.isArray(e) ? e : [e];
283
+ }
284
+ function le(e, o) {
285
+ K(o), Q("seer", ie);
286
+ const t = (r) => {
287
+ r.component(e.name, e);
288
+ };
289
+ e.install = t;
290
+ }
291
+ const w = Z({
292
+ name: "IxChart",
293
+ inheritAttrs: !1,
294
+ setup(e, { attrs: o }) {
295
+ const { containerRef: t } = oe(o);
296
+ return { containerRef: t };
297
+ },
298
+ render() {
299
+ const { class: e, style: o } = this.$attrs, t = ae({
300
+ class: e,
301
+ style: _({
302
+ width: "100%",
303
+ height: "100%",
304
+ ...o
305
+ })
306
+ });
307
+ return q("div", { ref: "containerRef", ...t });
308
+ }
309
+ });
310
+ le(w, [
311
+ T,
312
+ W,
313
+ I,
314
+ G,
315
+ M,
316
+ V,
317
+ j,
318
+ H
319
+ ]);
320
+ const xe = w;
321
+ export {
322
+ xe as IxChart,
323
+ ve as convertArray,
324
+ le as createInstall,
325
+ Ce as filterEmptyProps,
326
+ ge as isVertical,
327
+ ae as mergeAttrs,
328
+ se as seerColors,
329
+ he as seerColorsForMore,
330
+ me as seerColorsForRisk,
331
+ ie as seerTheme,
332
+ oe as useChart
333
+ };
@@ -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,y,W,r,g,C){"use strict";function M(e,n,t){let i;r.watch([e,n,t],([s,f,u],F,p)=>{!s||!f||(u?(i??(i=g.throttle(()=>f.resize(),16)),G(s,i)):A(s,i),p(()=>A(s,i)))})}const h=new Map;function G(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(F=>F(u)))});s.observe(e,t),h.set(e,{listeners:i,ro:s})}}function A(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)))}const x={text:"加载中..."};function m(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),F=r.computed(()=>r.unref(e).loading),p=r.computed(()=>r.unref(e).setOptionOpts),L=r.computed(()=>r.unref(e).theme??"seer"),B=()=>{const c=n.value;if(!c)return;const a=g.init(c,L.value,u.value),d=r.unref(e),{restOptions:I,events:D}=w(d,!1);a.setOption(I,p.value),i.value=C.cloneDeep(I),D.forEach(([q,v,$])=>{let O=v;$&&(O=(...J)=>{v(...J),a.off(q,O)}),a.on(q,O)}),d.onReady&&d.onReady(a),t.value=a},T=()=>{t.value&&(t.value.dispose(),t.value=void 0)};return r.onMounted(()=>B()),r.onBeforeUnmount(()=>T()),r.watch(()=>r.unref(e),c=>{const a=t.value;if(!a)return;const{restOptions:d}=w(c);C.isEqual(d,i.value)||(a.setOption(d,p.value),i.value=C.cloneDeep(d))},{deep:!0}),r.watch([L,u],()=>{T(),B()}),r.watchEffect(()=>{const c=f.value;c&&t.value&&(t.value.group=c)}),r.watchEffect(()=>{const c=t.value;if(!c)return;const a=F.value;a?c.showLoading(C.isBoolean(a)?x:{...x,...a}):c.hideLoading()}),M(n,t,s),{containerRef:n,chartRef:t}}function V(e){return/^on[^a-z]/.test(e)}const j=["class","style","autoResize","group","loading","setOptionOpts","theme","onReady"];function w(e,n=!0){const t={},i=[];return Object.keys(e).forEach(s=>{if(!j.includes(s)){if(V(s)){if(n)return;const f=e[s];if(f){const u=s.endsWith("Once"),F=u?s.length-4:void 0,p=s.charAt(2).toLowerCase()+s.substring(3,F);i.push([p,f,u])}return}t[s]=e[s]}}),{restOptions:t,events:i}}const E=["#458FFF","#45D9A3","#FFC145","#F5654F","#6A6AFD","#6ED1FF","#008787","#FF9245","#F587B3","#8352CC","#65779B"],P=["#458FFF","#C8DEFF","#45D9A3","#C8F4E4","#FFC145","#FFEDC8","#F5654F","#FCD1CB","#6A6AFD","#D3D3FE","#6ED1FF","#D3D3FE","#008787","#B3DBDB","#FF9245","#FFDFC8","#F587B3","#FCDBE8","#8352CC","#FCDBE8","#65779B","#65779B"],_=["#8C1604","#DB4C35","#FF9245","#FFC145","#689FFF","#45D9A3","#99ACD1"],R={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,radius:["70%","80%"],itemStyle:{borderWidth:1,borderColor:"#fff"},label:{show:!1,color:"#2F3540",formatter:"{c}",position:"inside"}},legend:{itemWidth:12,itemHeight:12,textStyle:{color:"#6F7785",fontSize:"12px"}},title:{itemGap:4,textStyle:{color:"#2F3540",fontSize:"12px",fontWeight:500},subtextStyle:{color:"#6F7785",fontSize:"12px"}},tooltip:{borderWidth:0,padding:12,textStyle:{color:"#2F3540"},axisPointer:{z:1,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:16}};function H(e){return!!(e&&e.xAxis&&e.xAxis.data)}function S(e,n){const t={...e,...n};return r.isVue2?{attrs:t}:t}function N(e){return Object.entries(e).reduce((n,[t,i])=>(i!==void 0&&(n[t]=i),n),{})}function U(e){return C.isNil(e)?[]:Array.isArray(e)?e:[e]}function b(e,n){g.use(n),g.registerTheme("seer",R);const t=i=>{i.component(e.name,e)};e.install=t}const z=r.defineComponent({name:"IxChart",inheritAttrs:!1,setup(e,{attrs:n}){const{containerRef:t}=m(n);return{containerRef:t}},render(){const{class:e,style:n}=this.$attrs,t=S({class:e,style:r.normalizeStyle({width:"100%",height:"100%",...n})});return r.h("div",{ref:"containerRef",...t})}});b(z,[l.DataZoomComponent,l.LegendComponent,l.GridComponent,l.TitleComponent,l.TooltipComponent,y.LabelLayout,y.UniversalTransition,W.SVGRenderer]);const Z=z;o.IxChart=Z,o.convertArray=U,o.createInstall=b,o.filterEmptyProps=N,o.isVertical=H,o.mergeAttrs=S,o.seerColors=E,o.seerColorsForMore=P,o.seerColorsForRisk=_,o.seerTheme=R,o.useChart=m,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 seerColorsForMore: string[];
3
+ export declare const seerColorsForRisk: string[];
3
4
  export declare const seerTheme: {
4
5
  color: string[];
5
6
  textStyle: {
6
7
  color: string;
7
8
  fontSize: string;
8
9
  };
10
+ bar: {
11
+ barGap: number;
12
+ barWidth: number;
13
+ label: {
14
+ color: string;
15
+ position: string;
16
+ };
17
+ };
18
+ line: {
19
+ label: {
20
+ color: string;
21
+ position: string;
22
+ };
23
+ };
9
24
  pie: {
10
25
  avoidLabelOverlap: boolean;
11
- 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.4.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"})});