@baishuyun/ui-business 4.1.0 → 4.1.1

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.
@@ -1,13 +1,13 @@
1
- import { jsxs as A, jsx as a } from "react/jsx-runtime";
2
- import { useRef as y, useEffect as m } from "react";
3
- import { d as _, i as w } from "../vendors/echarts.js";
4
- import { c as g } from "../vendors/clsx.js";
5
- const f = {
1
+ import { jsxs as w, jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as S, useRef as b, useImperativeHandle as z, useEffect as F } from "react";
3
+ import { d as L, i as C } from "../vendors/echarts.js";
4
+ import { c as f } from "../vendors/clsx.js";
5
+ const u = {
6
6
  "scatter-plot-page": "_scatter-plot-page_1h1ig_1",
7
7
  "xAxis-title": "_xAxis-title_1h1ig_6",
8
8
  "yAxis-title": "_yAxis-title_1h1ig_11"
9
- }, R = (t) => {
10
- const r = y(null), d = y(null), v = (i) => {
9
+ }, R = (t, p) => {
10
+ const d = b(null), x = b(null), A = (i) => {
11
11
  const n = {
12
12
  index0: [],
13
13
  // 所有系列的第一个数据(data[0])
@@ -17,10 +17,10 @@ const f = {
17
17
  return i.forEach((e) => {
18
18
  n.index0.push(e.data[0]), n.index1.push(e.data[1]);
19
19
  }), n;
20
- }, u = (i) => {
21
- const n = Math.max(...i), e = Math.min(...i), o = (i.reduce((l, b) => l + b, 0) / i.length).toFixed(2);
20
+ }, h = (i) => {
21
+ const n = Math.max(...i), e = Math.min(...i), o = (i.reduce((r, _) => r + _, 0) / i.length).toFixed(2);
22
22
  return { max: n, min: e, avg: Number(o) };
23
- }, h = v(t.dataList), x = u(h.index0), c = u(h.index1), s = {
23
+ }, y = A(t.dataList), c = h(y.index0), g = h(y.index1), v = t.options.xFields[t.options.xFields.length - 1].colors, s = {
24
24
  xAxis: {
25
25
  axisLabel: {
26
26
  color: "#666666",
@@ -145,30 +145,30 @@ const f = {
145
145
  show: !0,
146
146
  position: "end",
147
147
  // 标签位置:start/middle/end
148
- formatter: (l) => {
148
+ formatter: (r) => {
149
149
  if (e.is_label_visible && e.is_value_visible)
150
- return e.label + ":" + l.value;
150
+ return e.label + ":" + r.value;
151
151
  if (e.is_label_visible)
152
152
  return e.label;
153
153
  if (e.is_value_visible)
154
- return l.value;
154
+ return r.value;
155
155
  },
156
156
  // 格式化文本({b}名称,{c}数值)
157
157
  fontSize: 12,
158
158
  color: e.color
159
159
  }
160
160
  };
161
- 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 = x.max), e.aggregate === "min" && (o.xAxis = x.min), e.aggregate === "avg" && (o.xAxis = x.avg)), e.field === t.options.yFields[0].tag && (e.aggregate === "max" && (o.yAxis = c.max), e.aggregate === "min" && (o.yAxis = c.min), e.aggregate === "avg" && (o.yAxis = c.avg)), o.type, e.aggregate), o;
161
+ 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 = c.max), e.aggregate === "min" && (o.xAxis = c.min), e.aggregate === "avg" && (o.xAxis = c.avg)), e.field === t.options.yFields[0].tag && (e.aggregate === "max" && (o.yAxis = g.max), e.aggregate === "min" && (o.yAxis = g.min), e.aggregate === "avg" && (o.yAxis = g.avg)), o.type, e.aggregate), o;
162
162
  })
163
163
  },
164
- color: "",
164
+ color: v.find((e) => e.title === i.name) ? v.find((e) => e.title === i.name).color : "",
165
165
  label: {
166
166
  show: t.options.chart_label.enable,
167
167
  position: "top",
168
168
  // 文本在散点上方
169
169
  distance: 5,
170
170
  // 与散点的距离(避免紧贴)
171
- formatter: () => `${t.options.chart_label.dimension.enable ? i.name : ""} ${t.options.chart_label.value.enable ? "(" + i.data[0] + "," + i.data[1] + ")" : ""}`,
171
+ formatter: () => `${t.options.chart_label.dimension?.enable ? i.name : ""} ${t.options.chart_label.value?.enable ? "(" + i.data[0] + "," + i.data[1] + ")" : ""}`,
172
172
  textStyle: {
173
173
  fontSize: 11,
174
174
  color: "#666",
@@ -178,38 +178,44 @@ const f = {
178
178
  },
179
179
  type: "scatter"
180
180
  }))
181
- }, p = () => {
182
- if (!r.current) return;
183
- d.current && _(d.current);
184
- const i = w(r.current);
185
- d.current = i, i.setOption(s), t.onChartReady && t.onChartReady(i);
186
- const n = () => {
187
- i.resize();
181
+ };
182
+ let a = {};
183
+ const m = () => {
184
+ if (!d.current) return;
185
+ x.current && L(x.current), a = C(d.current), x.current = a, a.setOption(s), a.on("click", function(n) {
186
+ t.onChartClick && t.onChartClick(n, t.options, t.dataList);
187
+ }), t.onChartReady && t.onChartReady(a);
188
+ const i = () => {
189
+ a.resize();
188
190
  };
189
- return window.addEventListener("resize", n), () => {
190
- window.removeEventListener("resize", n), i.dispose();
191
+ return window.addEventListener("resize", i), () => {
192
+ window.removeEventListener("resize", i), a.dispose();
191
193
  };
192
194
  };
193
- return m(() => p(), [s]), /* @__PURE__ */ A("div", { className: g(f["scatter-plot-page"]), children: [
194
- /* @__PURE__ */ a("div", { ref: r, style: { width: "100%", height: "100%" } }),
195
- /* @__PURE__ */ a(
195
+ return z(p, () => ({
196
+ resizeEchart: () => {
197
+ a.resize();
198
+ }
199
+ })), F(() => m(), [s]), /* @__PURE__ */ w("div", { className: f(u["scatter-plot-page"]), children: [
200
+ /* @__PURE__ */ l("div", { ref: d, style: { width: "100%", height: "100%" } }),
201
+ /* @__PURE__ */ l(
196
202
  "div",
197
203
  {
198
- className: g(f["xAxis-title"]),
204
+ className: f(u["xAxis-title"]),
199
205
  style: s.xAxis?.position === "bottom" ? { bottom: "20px" } : s.xAxis?.position === "top" ? { top: "20px" } : void 0,
200
- children: /* @__PURE__ */ a("span", { children: s.xAxis?.title })
206
+ children: /* @__PURE__ */ l("span", { children: s.xAxis?.title })
201
207
  }
202
208
  ),
203
- /* @__PURE__ */ a(
209
+ /* @__PURE__ */ l(
204
210
  "div",
205
211
  {
206
- className: g(f["yAxis-title"]),
212
+ className: f(u["yAxis-title"]),
207
213
  style: s.yAxis?.position === "left" ? { left: "20px" } : s.yAxis?.position === "right" ? { right: "20px" } : void 0,
208
- children: /* @__PURE__ */ a("span", { children: s.yAxis?.title })
214
+ children: /* @__PURE__ */ l("span", { children: s.yAxis?.title })
209
215
  }
210
216
  )
211
217
  ] });
212
- };
218
+ }, N = S(R);
213
219
  export {
214
- R as S
220
+ N as S
215
221
  };
@@ -1,4 +1,4 @@
1
- import { S as a } from "./Scatterplot-CD1c18zN.js";
1
+ import { S as a } from "./Scatterplot-DFOLhAMO.js";
2
2
  export {
3
3
  a as default
4
4
  };
@@ -1,3 +1,3 @@
1
1
  import { ScatterplotConfig } from './Scatterplot.type';
2
- declare const Scatterplot: React.FC<ScatterplotConfig>;
3
- export default Scatterplot;
2
+ declare const _default: import('react').ForwardRefExoticComponent<ScatterplotConfig & import('react').RefAttributes<unknown>>;
3
+ export default _default;
@@ -27,13 +27,16 @@ type ScatterplotConfig = {
27
27
  position?: string;
28
28
  };
29
29
  chart_label: {
30
- value: {
30
+ enable: boolean;
31
+ dimension?: {
31
32
  enable: boolean;
32
33
  };
33
- dimension: {
34
+ value?: {
35
+ enable: boolean;
36
+ };
37
+ value_percent?: {
34
38
  enable: boolean;
35
39
  };
36
- enable: boolean;
37
40
  };
38
41
  legend: {
39
42
  enable: boolean;
@@ -55,5 +58,6 @@ type ScatterplotConfig = {
55
58
  name: string;
56
59
  }>;
57
60
  onChartReady?: (data: any) => void;
61
+ onChartClick?: (data: any, options: any, dataList: any) => void;
58
62
  };
59
63
  export type { ScatterplotConfig };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./vendors/simplebar-react.js";
2
2
  import { D as t, g as a } from "./DeptsMember/DeptsMember-BNuoQ8y4.js";
3
3
  import { C as p } from "./ConfigProvider/ConfigProvider-CAq3dN6-.js";
4
- import { S as m } from "./Scatterplot/Scatterplot-CD1c18zN.js";
4
+ import { S as m } from "./Scatterplot/Scatterplot-DFOLhAMO.js";
5
5
  import { a as c, g as f, s as S } from "./vendors/services/apiService.js";
6
6
  import { r as v } from "./DeptsMember/index-BRIA1uOQ.js";
7
7
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baishuyun/ui-business",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "百数云业务组件库",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",