@baishuyun/ui-business 5.0.2 → 5.0.3

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.
@@ -0,0 +1,209 @@
1
+ import { jsxs as Z, jsx as y } from "react/jsx-runtime";
2
+ import { c as v } from "../vendors/clsx.js";
3
+ import { i as D } from "../vendors/echarts.js";
4
+ import { forwardRef as tt, useRef as w, useState as et, useImperativeHandle as it, useEffect as j } from "react";
5
+ function F(e, g, s, r, x) {
6
+ let f = 0, u = 0;
7
+ const m = parseInt(r.fontSize) || 10, h = e.series.map((t) => t.data[0][0].toString()), l = e.series.map((t) => t.data[0][1].toString()), H = e.series.map((t) => t.name);
8
+ function A(t) {
9
+ let n = "";
10
+ if (t.fontSize || t.fontFamily || t.fontWeight) {
11
+ let i = "";
12
+ typeof t.fontSize == "string" && (t.fontSize.indexOf("px") !== -1 || t.fontSize.indexOf("rem") !== -1 || t.fontSize.indexOf("em") !== -1) ? i = t.fontSize : isNaN(+t.fontSize) ? i = "12px" : i = t.fontSize + "px", n = [t.fontStyle, t.fontWeight, i, t.fontFamily || "sans-serif"].join(
13
+ " "
14
+ );
15
+ }
16
+ return n && n.trim() || t.textFont || t.font;
17
+ }
18
+ function S(t, n) {
19
+ n.fontSize = parseInt(n.fontSize), n.fontFamily = n.fontFamily || "verdana";
20
+ const i = A(n), o = document.createElement("canvas").getContext("2d") || {};
21
+ return o.font = i, o?.measureText(t)?.width || 0;
22
+ }
23
+ function k(t, n) {
24
+ if (Array.isArray(t))
25
+ for (let i = 0, c = t.length; i < c && n.apply(t[i], [i, t[i]]) !== !1; i++) ;
26
+ else if (t && typeof t == "object") {
27
+ for (const i in t)
28
+ if (Object.prototype.hasOwnProperty.call(t, i) && n.apply(t[i], [i, t[i]]) === !1) break;
29
+ }
30
+ }
31
+ function O() {
32
+ let t = 0;
33
+ if (e.xAxis && e.xAxis.axisLabel) {
34
+ const n = e.xAxis.axisLabel.rotate;
35
+ if (n && n !== 0) {
36
+ let i = 0, c = "";
37
+ if (h && Array.isArray(h) && h.forEach((o) => {
38
+ const a = o;
39
+ a.length > i && (i = a.length, c = a);
40
+ }), i > 0) {
41
+ const o = S(c, e.xAxis.axisLabel), a = Math.abs(n) * Math.PI / 180;
42
+ t = o * Math.sin(a);
43
+ }
44
+ }
45
+ }
46
+ return t;
47
+ }
48
+ function R() {
49
+ let t = 0;
50
+ if (e.yAxis && e.yAxis.axisLabel) {
51
+ const n = e.yAxis.axisLabel.rotate;
52
+ if (n && n !== 0) {
53
+ let i = 0, c = "";
54
+ if (l && Array.isArray(l) && l.forEach((o) => {
55
+ const a = o;
56
+ a.length > i && (i = a.length, c = a);
57
+ }), i > 0) {
58
+ const o = S(c, e.yAxis.axisLabel);
59
+ if (n === 0)
60
+ t = o;
61
+ else if (n === 90)
62
+ t = parseInt(e.yAxis.axisLabel.fontSize) || 12;
63
+ else {
64
+ const a = Math.abs(n) * Math.PI / 180;
65
+ t = o * Math.cos(a);
66
+ }
67
+ t += 10;
68
+ }
69
+ }
70
+ }
71
+ return t;
72
+ }
73
+ function N() {
74
+ let t = 0;
75
+ const n = Array.isArray(g) ? g.length : Object.keys(g || {}).length;
76
+ return n > 10 ? t = 20 : n > 5 && (t = 10), t;
77
+ }
78
+ if (e.legend.type === "scroll")
79
+ return m + 10 + O() + R() + N();
80
+ k(g, (t, n) => {
81
+ const i = S(
82
+ n,
83
+ r || {
84
+ fontFamily: "verdana",
85
+ fontSize: 10,
86
+ fontStyle: "normal",
87
+ fontWeight: "normal"
88
+ }
89
+ );
90
+ u += i + 10 + 14 + 5, u > s && (f++, u = i + 10 + 14 + 5);
91
+ });
92
+ function G(t, n, i, c) {
93
+ const o = c.legend;
94
+ if (!o.show)
95
+ return 0;
96
+ const a = i.itemHeight + i.padding, $ = 10, q = 20, J = o.itemWidth || 12, K = t.map((d) => d.name || d), Q = (d) => {
97
+ const L = (d.match(/[\u4e00-\u9fa5]/g) || []).length, W = d.length - L;
98
+ return L * 12 + W * 7;
99
+ };
100
+ if (c.legend.left === "left" || c.legend.right === "right") {
101
+ const d = Math.max(...K.map((V) => Q(V))), L = J + 5 + d, W = Math.ceil(a * t.length / n), U = L + $;
102
+ return W * U + q;
103
+ }
104
+ return 0;
105
+ }
106
+ const b = G(H, x, e.legend, e), z = (f + 1) * (m + 10), C = O(), I = R();
107
+ let _ = -5, p = -5, E = -5, M = -5;
108
+ const B = () => {
109
+ let t = 20;
110
+ return e.xAxis.position === "bottom" && (t += C + 10), e.legend.show && (e.legend.top === "bottom" || e.legend.top === "") && (_ += z, t += z), e.xAxis.title !== "" && e.xAxis.position === "bottom" && (t = t + 30), t;
111
+ }, P = () => {
112
+ let t = 20;
113
+ return e.xAxis.position === "top" && (t += C + 10), e.legend.show && e.legend.top === "top" && (p += z, t += z), e.xAxis.title !== "" && e.xAxis.position === "top" && (t = t + 30), t;
114
+ }, X = () => {
115
+ let t = 20;
116
+ return e.yAxis.position === "left" && (t += I), e.legend.show && e.legend.left === "left" && (E += b, t += b), e.yAxis.title !== "" && e.yAxis.position === "left" && (t = t + 10), t;
117
+ }, Y = () => {
118
+ let t = 20 + I;
119
+ return e.yAxis.position === "right" && (t += 10), e.legend.show && e.legend.left === "right" && (M += b, t += b), e.yAxis.title !== "" && e.yAxis.position === "right" && (t = t + 30), t;
120
+ };
121
+ return {
122
+ grid: {
123
+ top: P(),
124
+ bottom: B(),
125
+ left: X(),
126
+ right: Y()
127
+ },
128
+ titleBottomHeight: _,
129
+ titleTopHeight: p,
130
+ titleLeftHeight: E,
131
+ titleRightHeight: M
132
+ };
133
+ }
134
+ const T = {
135
+ "auto-grid-echart": "_auto-grid-echart_w04s7_1",
136
+ "xAxis-title": "_xAxis-title_w04s7_6",
137
+ "yAxis-title": "_yAxis-title_w04s7_11"
138
+ }, nt = (e, g) => {
139
+ const s = w(null), r = w(null), x = w(null), [f, u] = et({}), m = e.dataList.map((l) => l.name), h = () => s.current ? (u(
140
+ F(
141
+ e.option,
142
+ m,
143
+ s.current.offsetWidth,
144
+ e.option.legend.textStyle,
145
+ s.current.offsetHeight
146
+ )
147
+ ), {
148
+ ...e.option,
149
+ grid: F(
150
+ e.option,
151
+ m,
152
+ s.current.offsetWidth,
153
+ e.option.legend.textStyle,
154
+ s.current.offsetHeight
155
+ ).grid
156
+ }) : {
157
+ ...e.option
158
+ };
159
+ return it(g, () => ({
160
+ resizeEchart: () => {
161
+ r.current?.resize();
162
+ }
163
+ })), j(() => {
164
+ if (!s.current) return;
165
+ r.current = D(s.current);
166
+ const l = h();
167
+ r.current.setOption(l, !0), r.current.on("click", function(A) {
168
+ e.onChartClick && e.onChartClick(A, e.options, e.dataList);
169
+ });
170
+ const H = () => {
171
+ if (r.current) {
172
+ const A = h();
173
+ r.current.setOption(A, !1);
174
+ }
175
+ };
176
+ return setTimeout(H, 100), e.onChartReady && e.onChartReady(r.current), x.current = new ResizeObserver(() => {
177
+ r.current?.resize(), setTimeout(H, 50);
178
+ }), s.current && x.current.observe(s.current), () => {
179
+ x.current?.disconnect(), r.current?.dispose();
180
+ };
181
+ }, []), j(() => {
182
+ if (!r.current) return;
183
+ const l = h();
184
+ r.current.setOption(l, !0);
185
+ }, [e.option]), /* @__PURE__ */ Z("div", { className: v(e.className, T["auto-grid-echart"]), children: [
186
+ /* @__PURE__ */ y("div", { ref: s, style: { width: "100%", height: "100%", ...e.style } }),
187
+ /* @__PURE__ */ y(
188
+ "div",
189
+ {
190
+ className: v(T["xAxis-title"]),
191
+ style: e.option.xAxis?.position === "bottom" ? {
192
+ bottom: f.titleBottomHeight + 20
193
+ } : e.option.xAxis?.position === "top" ? { top: f.titleTopHeight + 20 } : void 0,
194
+ children: /* @__PURE__ */ y("span", { children: e.option.xAxis?.title })
195
+ }
196
+ ),
197
+ /* @__PURE__ */ y(
198
+ "div",
199
+ {
200
+ className: v(T["yAxis-title"]),
201
+ style: e.option.yAxis?.position === "left" ? { left: f.titleLeftHeight } : e.option.yAxis?.position === "right" ? { right: f.titleRightHeight + 20 } : void 0,
202
+ children: /* @__PURE__ */ y("span", { children: e.option.yAxis?.title })
203
+ }
204
+ )
205
+ ] });
206
+ }, ct = tt(nt);
207
+ export {
208
+ ct as A
209
+ };
@@ -1,28 +1,28 @@
1
1
  import { jsx as h } from "react/jsx-runtime";
2
- import { forwardRef as y, useRef as v, useImperativeHandle as m } from "react";
3
- import { R as A } from "../vendors/echarts.js";
4
- import { A as S } from "./AutoGridEChart-vNNqSiqF.js";
5
- const w = (t, g) => {
6
- const r = v(null), c = (o) => {
2
+ import { R as y } from "../vendors/echarts.js";
3
+ import { forwardRef as v, useRef as m, useImperativeHandle as A } from "react";
4
+ import { A as S } from "./AutoGridEChart-BlLcIZ_T.js";
5
+ const p = (t, g) => {
6
+ const r = m(null), c = (i) => {
7
7
  const n = {
8
8
  index0: [],
9
9
  // 所有系列的第一个数据(data[0])
10
10
  index1: []
11
11
  // 所有系列的第二个数据(data[1])
12
12
  };
13
- return o.forEach((e) => {
13
+ return i.forEach((e) => {
14
14
  n.index0.push(e.data[0]), n.index1.push(e.data[1]);
15
15
  }), n;
16
- }, d = (o) => {
17
- const n = Math.max(...o), e = Math.min(...o), i = (o.reduce((a, b) => a + b, 0) / o.length).toFixed(2);
18
- return { max: n, min: e, avg: Number(i) };
16
+ }, d = (i) => {
17
+ const n = Math.max(...i), e = Math.min(...i), o = (i.reduce((a, b) => a + b, 0) / i.length).toFixed(2);
18
+ return { max: n, min: e, avg: Number(o) };
19
19
  }, x = c(t.dataList), l = d(x.index0), s = d(x.index1), f = t.options.xFields[t.options.xFields.length - 1].colors || [], u = {
20
20
  xAxis: {
21
21
  axisLabel: {
22
22
  color: "#666666",
23
23
  fontSize: 10,
24
24
  show: !0,
25
- rotate: t.options.xAxis?.label?.rotation + " " || 45
25
+ rotate: t.options.xAxis?.label?.rotation?.toString() || "45"
26
26
  // 文字顺时针旋转 90°(完全竖向)
27
27
  },
28
28
  min: t.options.xAxis?.min || void 0,
@@ -76,9 +76,9 @@ const w = (t, g) => {
76
76
  // 内边距(上下左右)
77
77
  borderRadius: 4,
78
78
  // 圆角半径
79
- formatter: (o) => {
80
- let n = `<div>${o.seriesName}</div>`;
81
- return n += `<div><span>${t.options.xFields[0].title}:</span><span>${o.value[0]}</span></div>`, n += `<div><span>${t.options.yFields[0].title}:</span><span>${o.value[1]}</span></div>`, o.componentType === "series" ? n : "";
79
+ formatter: (i) => {
80
+ let n = `<div>${i.seriesName}</div>`;
81
+ return n += `<div><span>${t.options.xFields[0].title}:</span><span>${i.value[0]}</span></div>`, n += `<div><span>${t.options.yFields[0].title}:</span><span>${i.value[1]}</span></div>`, i.componentType === "series" ? n : "";
82
82
  },
83
83
  triggerOn: "mousemove",
84
84
  // 触发时机:mousemove(鼠标移动)/ click(点击)/ mousemove|click(两者)
@@ -97,16 +97,17 @@ const w = (t, g) => {
97
97
  // 居右
98
98
  top: ["top", "bottom"].includes(t.options.legend.position) && t.options.legend.position || "middle",
99
99
  // 垂直居中
100
- // itemGap: 10, // 图例项间距 20px
100
+ itemGap: 10,
101
+ // 图例项间距 20px
101
102
  bottom: 0,
102
103
  padding: 10,
103
104
  itemWidth: 12,
104
- itemHeight: 12,
105
+ itemHeight: 14,
105
106
  textStyle: {
106
107
  fontStyle: "normal"
107
108
  }
108
109
  },
109
- graphic: t.options.guideline?.map((o) => ({
110
+ graphic: t.options.guideline?.map((i) => ({
110
111
  type: "line",
111
112
  // 类型:线
112
113
  shape: {
@@ -118,17 +119,17 @@ const w = (t, g) => {
118
119
  // 终点(X=100,Y=50)→ 水平
119
120
  },
120
121
  style: {
121
- stroke: o.color,
122
+ stroke: i.color,
122
123
  // 线条颜色
123
124
  lineWidth: 2
124
125
  // 线条宽度
125
126
  }
126
127
  })),
127
- series: t.dataList.map((o, n) => ({
128
- symbolSize: () => (o.data[2] || 0) >= t.options.bubbleOptions.maxSize ? t.options.bubbleOptions.maxSize : (o.data[2] || 0) <= t.options.bubbleOptions.minSize ? t.options.bubbleOptions.minSize : o.data[2] || 10,
128
+ series: t.dataList.map((i, n) => ({
129
+ symbolSize: () => (i.data[2] || 0) >= t.options.bubbleOptions.maxSize ? t.options.bubbleOptions.maxSize : (i.data[2] || 0) <= t.options.bubbleOptions.minSize ? t.options.bubbleOptions.minSize : i.data[2] || 10,
129
130
  //气泡大小
130
- data: [o.data],
131
- name: o.name,
131
+ data: [i.data],
132
+ name: i.name,
132
133
  markLine: {
133
134
  // 1. 标记线整体样式
134
135
  symbol: ["none", "none"],
@@ -141,7 +142,7 @@ const w = (t, g) => {
141
142
  },
142
143
  // 2. 标记线的数据(关键)
143
144
  data: n === 0 && t.options.guideline?.map((e) => {
144
- const i = {
145
+ const o = {
145
146
  lineStyle: {
146
147
  // 线的样式
147
148
  color: e.color,
@@ -168,16 +169,16 @@ const w = (t, g) => {
168
169
  // 标签与线的距离
169
170
  }
170
171
  };
171
- return e.type === "fixed" && (e.field === t.options.xFields[0].tag && (i.xAxis = e.value || 0), e.field === t.options.yFields[0].tag && (i.yAxis = e.value || 0)), e.type === "dynamic" && (e.field === t.options.xFields[0].tag && (e.aggregate === "max" && (i.xAxis = l.max), e.aggregate === "min" && (i.xAxis = l.min), e.aggregate === "avg" && (i.xAxis = l.avg)), e.field === t.options.yFields[0].tag && (e.aggregate === "max" && (i.yAxis = s.max), e.aggregate === "min" && (i.yAxis = s.min), e.aggregate === "avg" && (i.yAxis = s.avg)), i.type = e.aggregate), i;
172
+ return e.type === "fixed" && (e.field === t.options.xFields[0].tag && (o.xAxis = e.value || 0), e.field === t.options.yFields[0].tag && (o.yAxis = e.value || 0)), e.type === "dynamic" && (e.field === t.options.xFields[0].tag && (e.aggregate === "max" && (o.xAxis = l.max), e.aggregate === "min" && (o.xAxis = l.min), e.aggregate === "avg" && (o.xAxis = l.avg)), e.field === t.options.yFields[0].tag && (e.aggregate === "max" && (o.yAxis = s.max), e.aggregate === "min" && (o.yAxis = s.min), e.aggregate === "avg" && (o.yAxis = s.avg)), o.type = e.aggregate), o;
172
173
  })
173
174
  },
174
- color: f.find((e) => e.title === o.name) ? f.find((e) => e.title === o.name).color : "",
175
+ color: f.find((e) => e.title === i.name) ? f.find((e) => e.title === i.name).color : "",
175
176
  label: {
176
177
  show: t.options.chart_label.enable,
177
178
  distance: 5,
178
179
  // 与气泡的距离(避免紧贴)
179
180
  position: "top",
180
- formatter: () => `${t.options.chart_label.dimension?.enable ? o.name : ""} ${t.options.chart_label.value?.enable ? "(" + o.data[0] + "," + o.data[1] + ")" : ""}`,
181
+ formatter: () => `${t.options.chart_label.dimension?.enable ? i.name : ""} ${t.options.chart_label.value?.enable ? "(" + i.data[0] + "," + i.data[1] + ")" : ""}`,
181
182
  textStyle: {
182
183
  fontSize: 11,
183
184
  color: "#666",
@@ -201,21 +202,21 @@ const w = (t, g) => {
201
202
  // 垂直偏移 3px(向下)
202
203
  shadowOpacity: 0.8,
203
204
  // 阴影透明度(0.8 适中,避免过暗)
204
- color: new A(0.4, 0.3, 1, [
205
+ color: new y(0.4, 0.3, 1, [
205
206
  {
206
207
  offset: 0,
207
- color: o.color && o.color[0] || "rgb(129, 227, 238)"
208
+ color: i.color && i.color[0] || "rgb(129, 227, 238)"
208
209
  },
209
210
  {
210
211
  offset: 1,
211
- color: o.color && o.color[1] || "rgb(25, 183, 207)"
212
+ color: i.color && i.color[1] || "rgb(25, 183, 207)"
212
213
  }
213
214
  ])
214
215
  },
215
216
  type: "scatter"
216
217
  }))
217
218
  };
218
- return m(g, () => ({
219
+ return A(g, () => ({
219
220
  resizeEchart: () => {
220
221
  r.current.resizeEchart();
221
222
  }
@@ -230,7 +231,7 @@ const w = (t, g) => {
230
231
  onChartClick: t.onChartClick
231
232
  }
232
233
  );
233
- }, F = y(w);
234
+ }, F = v(p);
234
235
  export {
235
236
  F as B
236
237
  };
@@ -1,4 +1,4 @@
1
- import { B as r } from "./BubbleChart-B0AuH-ma.js";
1
+ import { B as r } from "./BubbleChart-BPGhlxCM.js";
2
2
  export {
3
3
  r as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
2
  import { forwardRef as b, useRef as v, useImperativeHandle as m } from "react";
3
- import { A } from "../BubbleChart/AutoGridEChart-vNNqSiqF.js";
3
+ import { A } from "../BubbleChart/AutoGridEChart-BlLcIZ_T.js";
4
4
  const S = (t, c) => {
5
5
  const d = v(null), f = (i) => {
6
6
  const n = {
@@ -21,7 +21,7 @@ const S = (t, c) => {
21
21
  color: "#666666",
22
22
  fontSize: 10,
23
23
  show: !0,
24
- rotate: t.options.xAxis?.label?.rotation || 45
24
+ rotate: t.options.xAxis?.label?.rotation?.toString() || "45"
25
25
  // 文字顺时针旋转 90°(完全竖向)
26
26
  },
27
27
  min: t.options.xAxis?.min || void 0,
@@ -36,7 +36,7 @@ const S = (t, c) => {
36
36
  color: "#666666",
37
37
  fontSize: 10,
38
38
  show: !0,
39
- rotate: t.options.yAxis?.label?.rotation || 45
39
+ rotate: t.options.yAxis?.label?.rotation?.toString() || "45"
40
40
  // 文字顺时针旋转 90°(完全竖向)
41
41
  },
42
42
  min: t.options.yAxis?.min || void 0,
@@ -90,11 +90,12 @@ const S = (t, c) => {
90
90
  // 居右
91
91
  top: ["top", "bottom"].includes(t.options.legend.position) && t.options.legend.position || "middle",
92
92
  // 垂直居中
93
- // itemGap: 10, // 图例项间距 20px
93
+ itemGap: 10,
94
+ // 图例项间距 20px
94
95
  bottom: 0,
95
96
  padding: 10,
96
97
  itemWidth: 12,
97
- itemHeight: 12,
98
+ itemHeight: 14,
98
99
  textStyle: {
99
100
  fontStyle: "normal"
100
101
  }
@@ -1,4 +1,4 @@
1
- import { S as a } from "./Scatterplot-D8AUUxhA.js";
1
+ import { S as a } from "./Scatterplot-BL66B_Zm.js";
2
2
  export {
3
3
  a as default
4
4
  };
@@ -1,5 +1,5 @@
1
- import { default as React } from 'react';
2
1
  import { EChartsType } from 'echarts';
2
+ import { default as React } from 'react';
3
3
  interface AutoGridEChartProps {
4
4
  option: any;
5
5
  options: any;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./vendors/simplebar-react.js";
2
2
  import { D as B, g as I } from "./DeptsMember/DeptsMember-BNuoQ8y4.js";
3
3
  import { C as k } from "./ConfigProvider/ConfigProvider-CAq3dN6-.js";
4
- import { B as D } from "./BubbleChart/BubbleChart-B0AuH-ma.js";
5
- import { S as H } from "./Scatterplot/Scatterplot-D8AUUxhA.js";
4
+ import { B as D } from "./BubbleChart/BubbleChart-BPGhlxCM.js";
5
+ import { S as H } from "./Scatterplot/Scatterplot-BL66B_Zm.js";
6
6
  import { jsxs as r, jsx as o } from "react/jsx-runtime";
7
7
  import { i as _ } from "./vendors/echarts.js";
8
8
  import { forwardRef as v, useRef as b, useEffect as L, useImperativeHandle as y } from "react";
@@ -1 +1 @@
1
- export declare function getLegendHeight(optinos: any, Legend: any, elwdith: number, fontStyle: any): any;
1
+ export declare function getLegendHeight(optinos: any, Legend: any, elwdith: number, fontStyle: any, elheight: number): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-business",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "百数云业务组件库",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,212 +0,0 @@
1
- import { jsxs as G, jsx as A } from "react/jsx-runtime";
2
- import { forwardRef as P, useRef as z, useState as X, useImperativeHandle as Y, useEffect as _ } from "react";
3
- import { i as $ } from "../vendors/echarts.js";
4
- import { c as S } from "../vendors/clsx.js";
5
- function E(e, c, l, r) {
6
- let x = 0, f = 0;
7
- const y = parseInt(r.fontSize) || 10, u = e.series.map((t) => t.data[0][0].toString()), d = e.series.map((t) => t.data[0][1].toString());
8
- function h(t) {
9
- let i = "";
10
- if (t.fontSize || t.fontFamily || t.fontWeight) {
11
- let n = "";
12
- typeof t.fontSize == "string" && (t.fontSize.indexOf("px") !== -1 || t.fontSize.indexOf("rem") !== -1 || t.fontSize.indexOf("em") !== -1) ? n = t.fontSize : isNaN(+t.fontSize) ? n = "12px" : n = t.fontSize + "px", i = [t.fontStyle, t.fontWeight, n, t.fontFamily || "sans-serif"].join(
13
- " "
14
- );
15
- }
16
- return i && i.trim() || t.textFont || t.font;
17
- }
18
- function g(t, i) {
19
- i.fontSize = parseInt(i.fontSize), i.fontFamily = i.fontFamily || "verdana";
20
- const n = h(i), a = document.createElement("canvas").getContext("2d") || {};
21
- return a.font = n, a?.measureText(t)?.width || 0;
22
- }
23
- function m(t, i) {
24
- if (Array.isArray(t))
25
- for (let n = 0, s = t.length; n < s && i.apply(t[n], [n, t[n]]) !== !1; n++) ;
26
- else if (t && typeof t == "object") {
27
- for (const n in t)
28
- if (Object.prototype.hasOwnProperty.call(t, n) && i.apply(t[n], [n, t[n]]) === !1) break;
29
- }
30
- }
31
- function L() {
32
- let t = 0;
33
- if (e.xAxis && e.xAxis.axisLabel) {
34
- const i = e.xAxis.axisLabel.rotate;
35
- if (i && i !== 0) {
36
- let n = 0, s = "";
37
- if (u && Array.isArray(u) && u.forEach((a) => {
38
- const o = a;
39
- o.length > n && (n = o.length, s = o);
40
- }), n > 0) {
41
- const a = g(s, e.xAxis.axisLabel), o = Math.abs(i) * Math.PI / 180;
42
- t = a * Math.sin(o);
43
- }
44
- }
45
- }
46
- return t;
47
- }
48
- function w() {
49
- let t = 0;
50
- if (e.yAxis && e.yAxis.axisLabel) {
51
- const i = e.yAxis.axisLabel.rotate;
52
- if (i && i !== 0) {
53
- let n = 0, s = "";
54
- if (d && Array.isArray(d) && d.forEach((a) => {
55
- const o = a;
56
- o.length > n && (n = o.length, s = o);
57
- }), n > 0) {
58
- const a = g(s, e.yAxis.axisLabel);
59
- if (i === 0)
60
- t = a;
61
- else if (i === 90)
62
- t = parseInt(e.yAxis.axisLabel.fontSize) || 12;
63
- else {
64
- const o = Math.abs(i) * Math.PI / 180;
65
- t = a * Math.cos(o);
66
- }
67
- t += 10;
68
- }
69
- }
70
- }
71
- return t;
72
- }
73
- function F() {
74
- let t = 0;
75
- const i = Array.isArray(c) ? c.length : Object.keys(c || {}).length;
76
- return i > 10 ? t = 20 : i > 5 && (t = 10), t;
77
- }
78
- if (e.legend.type === "scroll")
79
- return y + 10 + L() + w() + F();
80
- m(c, (t, i) => {
81
- const n = g(
82
- i,
83
- r || {
84
- fontFamily: "verdana",
85
- fontSize: 10,
86
- fontStyle: "normal",
87
- fontWeight: "normal"
88
- }
89
- );
90
- f += n + 10 + 14 + 5, f > l && (x++, f = n + 10 + 14 + 5);
91
- });
92
- function j() {
93
- let t = 0;
94
- if (e.legend.show && e.legend.orient === "vertical") {
95
- let i = 0;
96
- m(c, (n, s) => {
97
- const a = g(
98
- s,
99
- r || {
100
- fontFamily: "verdana",
101
- fontSize: 10,
102
- fontStyle: "normal",
103
- fontWeight: "normal"
104
- }
105
- ) + 25;
106
- i = Math.max(i, a);
107
- }), (e.legend.left === "left" || e.legend.left === "right" || e.legend.right === "left" || e.legend.right === "right") && (t = i + 20);
108
- }
109
- return t;
110
- }
111
- const b = j(), H = (x + 1) * (y + 10), O = L(), W = w();
112
- let R = -5, C = -5, T = -5, I = -5;
113
- const M = () => {
114
- let t = 20;
115
- return e.xAxis.position === "bottom" && (t += O + 10), e.legend.show && (e.legend.top === "bottom" || e.legend.top === "") && (R += H, t += H), e.xAxis.title !== "" && e.xAxis.position === "bottom" && (t = t + 30), t;
116
- }, k = () => {
117
- let t = 20;
118
- return e.xAxis.position === "top" && (t += O + 10), e.legend.show && e.legend.top === "top" && (C += H, t += H), e.xAxis.title !== "" && e.xAxis.position === "top" && (t = t + 30), t;
119
- }, N = () => {
120
- let t = 20;
121
- return e.yAxis.position === "left" && (t += W), e.legend.show && e.legend.left === "left" && (T += b, t += b), e.yAxis.title !== "" && e.yAxis.position === "left" && (t = t + 10), t;
122
- }, B = () => {
123
- let t = 20 + W;
124
- return e.yAxis.position === "right" && (t += 10), e.legend.show && e.legend.left === "right" && (I += b, t += b), e.yAxis.title !== "" && e.yAxis.position === "right" && (t = t + 30), t;
125
- };
126
- return {
127
- grid: {
128
- top: k(),
129
- bottom: M(),
130
- left: N(),
131
- right: B()
132
- },
133
- titleBottomHeight: R,
134
- titleTopHeight: C,
135
- titleLeftHeight: T,
136
- titleRightHeight: I
137
- };
138
- }
139
- const v = {
140
- "auto-grid-echart": "_auto-grid-echart_w04s7_1",
141
- "xAxis-title": "_xAxis-title_w04s7_6",
142
- "yAxis-title": "_yAxis-title_w04s7_11"
143
- }, q = (e, c) => {
144
- const l = z(null), r = z(null), x = z(null), [f, y] = X({}), u = e.dataList.map((h) => h.name), d = () => l.current ? (y(
145
- E(
146
- e.option,
147
- u,
148
- l.current.offsetWidth,
149
- e.option.legend.textStyle
150
- )
151
- ), {
152
- ...e.option,
153
- grid: E(
154
- e.option,
155
- u,
156
- l.current.offsetWidth,
157
- e.option.legend.textStyle
158
- ).grid
159
- }) : {
160
- ...e.option
161
- };
162
- return Y(c, () => ({
163
- resizeEchart: () => {
164
- r.current?.resize();
165
- }
166
- })), _(() => {
167
- if (!l.current) return;
168
- r.current = $(l.current);
169
- const h = d();
170
- r.current.setOption(h, !0), r.current.on("click", function(m) {
171
- e.onChartClick && e.onChartClick(m, e.options, e.dataList);
172
- });
173
- const g = () => {
174
- if (r.current) {
175
- const m = d();
176
- r.current.setOption(m, !1);
177
- }
178
- };
179
- return setTimeout(g, 100), e.onChartReady && e.onChartReady(r.current), x.current = new ResizeObserver(() => {
180
- r.current?.resize(), setTimeout(g, 50);
181
- }), l.current && x.current.observe(l.current), () => {
182
- x.current?.disconnect(), r.current?.dispose();
183
- };
184
- }, []), _(() => {
185
- if (!r.current) return;
186
- const h = d();
187
- r.current.setOption(h, !0);
188
- }, [e.option]), /* @__PURE__ */ G("div", { className: S(e.className, v["auto-grid-echart"]), children: [
189
- /* @__PURE__ */ A("div", { ref: l, style: { width: "100%", height: "100%", ...e.style } }),
190
- /* @__PURE__ */ A(
191
- "div",
192
- {
193
- className: S(v["xAxis-title"]),
194
- style: e.option.xAxis?.position === "bottom" ? {
195
- bottom: f.titleBottomHeight + 20
196
- } : e.option.xAxis?.position === "top" ? { top: f.titleTopHeight + 20 } : void 0,
197
- children: /* @__PURE__ */ A("span", { children: e.option.xAxis?.title })
198
- }
199
- ),
200
- /* @__PURE__ */ A(
201
- "div",
202
- {
203
- className: S(v["yAxis-title"]),
204
- style: e.option.yAxis?.position === "left" ? { left: f.titleLeftHeight } : e.option.yAxis?.position === "right" ? { right: f.titleRightHeight + 20 } : void 0,
205
- children: /* @__PURE__ */ A("span", { children: e.option.yAxis?.title })
206
- }
207
- )
208
- ] });
209
- }, U = P(q);
210
- export {
211
- U as A
212
- };