@ant-design/agentic-ui 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Hooks/useIntersectionOnce.d.ts +5 -0
- package/dist/Hooks/useIntersectionOnce.js +79 -0
- package/dist/Plugins/chart/AreaChart/index.js +20 -9
- package/dist/Plugins/chart/BarChart/index.js +12 -1
- package/dist/Plugins/chart/ChartMark/Area.js +21 -10
- package/dist/Plugins/chart/ChartMark/Bar.js +19 -8
- package/dist/Plugins/chart/ChartMark/Column.js +19 -8
- package/dist/Plugins/chart/ChartMark/Line.js +20 -9
- package/dist/Plugins/chart/ChartMark/Pie.js +12 -1
- package/dist/Plugins/chart/ChartRender.js +182 -48
- package/dist/Plugins/chart/DonutChart/index.js +12 -1
- package/dist/Plugins/chart/FunnelChart/index.d.ts +2 -0
- package/dist/Plugins/chart/FunnelChart/index.js +69 -18
- package/dist/Plugins/chart/LineChart/index.js +20 -9
- package/dist/Plugins/chart/RadarChart/index.js +19 -8
- package/dist/Plugins/chart/ScatterChart/index.js +12 -1
- package/dist/Plugins/chart/loadChartRuntime.d.ts +18 -0
- package/dist/Plugins/chart/loadChartRuntime.js +91 -0
- package/dist/Plugins/defaultPlugins.d.ts +3 -0
- package/dist/Plugins/defaultPlugins.js +2 -0
- package/dist/Plugins/mermaid/Mermaid.d.ts +5 -2
- package/dist/Plugins/mermaid/Mermaid.js +131 -38
- package/dist/Plugins/mermaid/index.js +1 -1
- package/dist/TaskList/index.js +2 -8
- package/dist/TaskList/style.js +1 -7
- package/package.json +3 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface UseIntersectionOnceOptions extends Omit<IntersectionObserverInit, 'root'> {
|
|
3
|
+
root?: RefObject<Element | null> | Element | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const useIntersectionOnce: <T extends Element>(targetRef: RefObject<T>, options?: UseIntersectionOnceOptions) => boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/Hooks/useIntersectionOnce.ts
|
|
34
|
+
import { useEffect, useRef, useState } from "react";
|
|
35
|
+
var useIntersectionOnce = (targetRef, options = {}) => {
|
|
36
|
+
const _a = options, { root } = _a, restOptions = __objRest(_a, ["root"]);
|
|
37
|
+
const [isIntersecting, setIntersecting] = useState(false);
|
|
38
|
+
const observerRef = useRef(null);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isIntersecting)
|
|
41
|
+
return;
|
|
42
|
+
const element = targetRef.current;
|
|
43
|
+
if (!element)
|
|
44
|
+
return;
|
|
45
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
46
|
+
setIntersecting(true);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const resolvedRoot = root && "current" in root ? root.current : root;
|
|
50
|
+
observerRef.current = new IntersectionObserver(
|
|
51
|
+
(entries) => {
|
|
52
|
+
entries.forEach((entry) => {
|
|
53
|
+
var _a2;
|
|
54
|
+
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
|
55
|
+
setIntersecting(true);
|
|
56
|
+
(_a2 = observerRef.current) == null ? void 0 : _a2.disconnect();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
__spreadProps(__spreadValues({}, restOptions), { root: resolvedRoot != null ? resolvedRoot : null })
|
|
61
|
+
);
|
|
62
|
+
observerRef.current.observe(element);
|
|
63
|
+
return () => {
|
|
64
|
+
var _a2;
|
|
65
|
+
(_a2 = observerRef.current) == null ? void 0 : _a2.disconnect();
|
|
66
|
+
observerRef.current = null;
|
|
67
|
+
};
|
|
68
|
+
}, [
|
|
69
|
+
targetRef,
|
|
70
|
+
restOptions.rootMargin,
|
|
71
|
+
restOptions.threshold,
|
|
72
|
+
root,
|
|
73
|
+
isIntersecting
|
|
74
|
+
]);
|
|
75
|
+
return isIntersecting;
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
useIntersectionOnce
|
|
79
|
+
};
|
|
@@ -46,15 +46,7 @@ import {
|
|
|
46
46
|
findDataPointByXValue
|
|
47
47
|
} from "../utils";
|
|
48
48
|
import { useStyle } from "./style";
|
|
49
|
-
|
|
50
|
-
CategoryScale,
|
|
51
|
-
LinearScale,
|
|
52
|
-
PointElement,
|
|
53
|
-
LineElement,
|
|
54
|
-
Filler,
|
|
55
|
-
Tooltip,
|
|
56
|
-
Legend
|
|
57
|
-
);
|
|
49
|
+
var areaChartComponentsRegistered = false;
|
|
58
50
|
var hexToRgba = (hex, alpha) => {
|
|
59
51
|
const sanitized = hex.replace("#", "");
|
|
60
52
|
const isShort = sanitized.length === 3;
|
|
@@ -95,6 +87,25 @@ var AreaChart = ({
|
|
|
95
87
|
statistic: statisticConfig,
|
|
96
88
|
variant
|
|
97
89
|
}) => {
|
|
90
|
+
useMemo(() => {
|
|
91
|
+
if (areaChartComponentsRegistered) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
if (typeof window === "undefined") {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
ChartJS.register(
|
|
98
|
+
CategoryScale,
|
|
99
|
+
LinearScale,
|
|
100
|
+
PointElement,
|
|
101
|
+
LineElement,
|
|
102
|
+
Filler,
|
|
103
|
+
Tooltip,
|
|
104
|
+
Legend
|
|
105
|
+
);
|
|
106
|
+
areaChartComponentsRegistered = true;
|
|
107
|
+
return void 0;
|
|
108
|
+
}, []);
|
|
98
109
|
const safeData = Array.isArray(data) ? data : [];
|
|
99
110
|
const [windowWidth, setWindowWidth] = useState(
|
|
100
111
|
typeof window !== "undefined" ? window.innerWidth : 768
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
findDataPointByXValue
|
|
46
46
|
} from "../utils";
|
|
47
47
|
import { useStyle } from "./style";
|
|
48
|
-
|
|
48
|
+
var barChartComponentsRegistered = false;
|
|
49
49
|
var hexToRgba = (hex, alpha) => {
|
|
50
50
|
const sanitized = hex.replace("#", "");
|
|
51
51
|
const isShort = sanitized.length === 3;
|
|
@@ -93,6 +93,17 @@ var BarChart = ({
|
|
|
93
93
|
dataLabelFormatter,
|
|
94
94
|
chartOptions
|
|
95
95
|
}) => {
|
|
96
|
+
useMemo(() => {
|
|
97
|
+
if (barChartComponentsRegistered) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
if (typeof window === "undefined") {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
|
|
104
|
+
barChartComponentsRegistered = true;
|
|
105
|
+
return void 0;
|
|
106
|
+
}, []);
|
|
96
107
|
const safeData = Array.isArray(data) ? data : [];
|
|
97
108
|
const [windowWidth, setWindowWidth] = useState(
|
|
98
109
|
typeof window !== "undefined" ? window.innerWidth : 768
|
|
@@ -13,17 +13,28 @@ import {
|
|
|
13
13
|
import React, { useImperativeHandle, useRef } from "react";
|
|
14
14
|
import { Line } from "react-chartjs-2";
|
|
15
15
|
import { Container } from "./Container";
|
|
16
|
-
|
|
17
|
-
CategoryScale,
|
|
18
|
-
LinearScale,
|
|
19
|
-
PointElement,
|
|
20
|
-
LineElement,
|
|
21
|
-
Filler,
|
|
22
|
-
Title,
|
|
23
|
-
Tooltip,
|
|
24
|
-
Legend
|
|
25
|
-
);
|
|
16
|
+
var chartMarkAreaRegistered = false;
|
|
26
17
|
var Area = (props) => {
|
|
18
|
+
React.useMemo(() => {
|
|
19
|
+
if (chartMarkAreaRegistered) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
if (typeof window === "undefined") {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
ChartJS.register(
|
|
26
|
+
CategoryScale,
|
|
27
|
+
LinearScale,
|
|
28
|
+
PointElement,
|
|
29
|
+
LineElement,
|
|
30
|
+
Filler,
|
|
31
|
+
Title,
|
|
32
|
+
Tooltip,
|
|
33
|
+
Legend
|
|
34
|
+
);
|
|
35
|
+
chartMarkAreaRegistered = true;
|
|
36
|
+
return void 0;
|
|
37
|
+
}, []);
|
|
27
38
|
const chartRef = React.useRef(void 0);
|
|
28
39
|
const htmlRef = useRef(null);
|
|
29
40
|
const lineChartRef = useRef(null);
|
|
@@ -12,15 +12,26 @@ import React, { useImperativeHandle, useRef } from "react";
|
|
|
12
12
|
import { Bar as ChartBar } from "react-chartjs-2";
|
|
13
13
|
import { stringFormatNumber } from "../utils";
|
|
14
14
|
import { Container } from "./Container";
|
|
15
|
-
|
|
16
|
-
CategoryScale,
|
|
17
|
-
LinearScale,
|
|
18
|
-
BarElement,
|
|
19
|
-
Title,
|
|
20
|
-
Tooltip,
|
|
21
|
-
Legend
|
|
22
|
-
);
|
|
15
|
+
var chartMarkBarRegistered = false;
|
|
23
16
|
var Bar = (props) => {
|
|
17
|
+
React.useMemo(() => {
|
|
18
|
+
if (chartMarkBarRegistered) {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
if (typeof window === "undefined") {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
ChartJS.register(
|
|
25
|
+
CategoryScale,
|
|
26
|
+
LinearScale,
|
|
27
|
+
BarElement,
|
|
28
|
+
Title,
|
|
29
|
+
Tooltip,
|
|
30
|
+
Legend
|
|
31
|
+
);
|
|
32
|
+
chartMarkBarRegistered = true;
|
|
33
|
+
return void 0;
|
|
34
|
+
}, []);
|
|
24
35
|
const chartRef = React.useRef(void 0);
|
|
25
36
|
const htmlRef = useRef(null);
|
|
26
37
|
const barChartRef = useRef(null);
|
|
@@ -12,15 +12,26 @@ import React, { useImperativeHandle, useRef } from "react";
|
|
|
12
12
|
import { Bar as ChartBar } from "react-chartjs-2";
|
|
13
13
|
import { stringFormatNumber } from "../utils";
|
|
14
14
|
import { Container } from "./Container";
|
|
15
|
-
|
|
16
|
-
CategoryScale,
|
|
17
|
-
LinearScale,
|
|
18
|
-
BarElement,
|
|
19
|
-
Title,
|
|
20
|
-
Tooltip,
|
|
21
|
-
Legend
|
|
22
|
-
);
|
|
15
|
+
var chartMarkColumnRegistered = false;
|
|
23
16
|
var Column = (props) => {
|
|
17
|
+
React.useMemo(() => {
|
|
18
|
+
if (chartMarkColumnRegistered) {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
if (typeof window === "undefined") {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
ChartJS.register(
|
|
25
|
+
CategoryScale,
|
|
26
|
+
LinearScale,
|
|
27
|
+
BarElement,
|
|
28
|
+
Title,
|
|
29
|
+
Tooltip,
|
|
30
|
+
Legend
|
|
31
|
+
);
|
|
32
|
+
chartMarkColumnRegistered = true;
|
|
33
|
+
return void 0;
|
|
34
|
+
}, []);
|
|
24
35
|
const chartRef = React.useRef(void 0);
|
|
25
36
|
const htmlRef = useRef(null);
|
|
26
37
|
const barChartRef = useRef(null);
|
|
@@ -13,16 +13,27 @@ import React, { useImperativeHandle, useRef } from "react";
|
|
|
13
13
|
import { Line as ChartLine } from "react-chartjs-2";
|
|
14
14
|
import { stringFormatNumber } from "../utils";
|
|
15
15
|
import { Container } from "./Container";
|
|
16
|
-
|
|
17
|
-
CategoryScale,
|
|
18
|
-
LinearScale,
|
|
19
|
-
PointElement,
|
|
20
|
-
LineElement,
|
|
21
|
-
Title,
|
|
22
|
-
Tooltip,
|
|
23
|
-
Legend
|
|
24
|
-
);
|
|
16
|
+
var chartMarkLineRegistered = false;
|
|
25
17
|
var Line = (props) => {
|
|
18
|
+
React.useMemo(() => {
|
|
19
|
+
if (chartMarkLineRegistered) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
if (typeof window === "undefined") {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
ChartJS.register(
|
|
26
|
+
CategoryScale,
|
|
27
|
+
LinearScale,
|
|
28
|
+
PointElement,
|
|
29
|
+
LineElement,
|
|
30
|
+
Title,
|
|
31
|
+
Tooltip,
|
|
32
|
+
Legend
|
|
33
|
+
);
|
|
34
|
+
chartMarkLineRegistered = true;
|
|
35
|
+
return void 0;
|
|
36
|
+
}, []);
|
|
26
37
|
const chartRef = React.useRef(void 0);
|
|
27
38
|
const htmlRef = useRef(null);
|
|
28
39
|
const lineChartRef = useRef(null);
|
|
@@ -4,8 +4,19 @@ import React, { useImperativeHandle, useRef } from "react";
|
|
|
4
4
|
import { Doughnut } from "react-chartjs-2";
|
|
5
5
|
import { defaultColorList } from "../const";
|
|
6
6
|
import { Container } from "./Container";
|
|
7
|
-
|
|
7
|
+
var chartMarkPieRegistered = false;
|
|
8
8
|
var Pie = (props) => {
|
|
9
|
+
React.useMemo(() => {
|
|
10
|
+
if (chartMarkPieRegistered) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
if (typeof window === "undefined") {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
ChartJS.register(ArcElement, Tooltip, Legend);
|
|
17
|
+
chartMarkPieRegistered = true;
|
|
18
|
+
return void 0;
|
|
19
|
+
}, []);
|
|
9
20
|
const chartRef = React.useRef(void 0);
|
|
10
21
|
const htmlRef = useRef(null);
|
|
11
22
|
const pieChartRef = useRef(null);
|
|
@@ -21,14 +21,10 @@ import { ProForm, ProFormSelect } from "@ant-design/pro-components";
|
|
|
21
21
|
import { ConfigProvider, Descriptions, Dropdown, Popover, Table } from "antd";
|
|
22
22
|
import React, { useContext, useMemo, useState } from "react";
|
|
23
23
|
import { ActionIconBox } from "../../Components/ActionIconBox";
|
|
24
|
+
import { Loading } from "../../Components/Loading";
|
|
25
|
+
import { useIntersectionOnce } from "../../Hooks/useIntersectionOnce";
|
|
24
26
|
import { I18nContext } from "../../I18n";
|
|
25
|
-
import
|
|
26
|
-
import BarChart from "./BarChart";
|
|
27
|
-
import DonutChart from "./DonutChart";
|
|
28
|
-
import FunnelChart from "./FunnelChart";
|
|
29
|
-
import LineChart from "./LineChart";
|
|
30
|
-
import RadarChart from "./RadarChart";
|
|
31
|
-
import ScatterChart from "./ScatterChart";
|
|
27
|
+
import { loadChartRuntime } from "./loadChartRuntime";
|
|
32
28
|
import { isNotEmpty, toNumber } from "./utils";
|
|
33
29
|
var getChartMap = (i18n) => {
|
|
34
30
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
@@ -95,6 +91,58 @@ var ChartRender = (props) => {
|
|
|
95
91
|
const i18n = useContext(I18nContext);
|
|
96
92
|
const [config, setConfig] = useState(() => props.config);
|
|
97
93
|
const [renderKey, setRenderKey] = useState(0);
|
|
94
|
+
const [runtime, setRuntime] = useState(null);
|
|
95
|
+
const [runtimeError, setRuntimeError] = useState(null);
|
|
96
|
+
const [isRuntimeLoading, setRuntimeLoading] = useState(false);
|
|
97
|
+
const containerRef = React.useRef(null);
|
|
98
|
+
const isIntersecting = useIntersectionOnce(containerRef);
|
|
99
|
+
const renderDescriptionsFallback = React.useMemo(() => {
|
|
100
|
+
var _a;
|
|
101
|
+
const columnCount = ((_a = config == null ? void 0 : config.columns) == null ? void 0 : _a.length) || 0;
|
|
102
|
+
return chartData.length < 2 && columnCount > 8;
|
|
103
|
+
}, [chartData, config == null ? void 0 : config.columns]);
|
|
104
|
+
const shouldLoadRuntime = chartType !== "table" && chartType !== "descriptions" && !renderDescriptionsFallback;
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (!shouldLoadRuntime)
|
|
107
|
+
return;
|
|
108
|
+
if (!isIntersecting)
|
|
109
|
+
return;
|
|
110
|
+
if (runtime)
|
|
111
|
+
return;
|
|
112
|
+
if (isRuntimeLoading)
|
|
113
|
+
return;
|
|
114
|
+
if (runtimeError)
|
|
115
|
+
return;
|
|
116
|
+
let cancelled = false;
|
|
117
|
+
setRuntimeLoading(true);
|
|
118
|
+
loadChartRuntime().then((module) => {
|
|
119
|
+
if (cancelled)
|
|
120
|
+
return;
|
|
121
|
+
setRuntime(module);
|
|
122
|
+
}).catch((error) => {
|
|
123
|
+
if (cancelled)
|
|
124
|
+
return;
|
|
125
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
126
|
+
setRuntimeError(message);
|
|
127
|
+
}).finally(() => {
|
|
128
|
+
if (cancelled)
|
|
129
|
+
return;
|
|
130
|
+
setRuntimeLoading(false);
|
|
131
|
+
});
|
|
132
|
+
return () => {
|
|
133
|
+
cancelled = true;
|
|
134
|
+
};
|
|
135
|
+
}, [
|
|
136
|
+
shouldLoadRuntime,
|
|
137
|
+
isIntersecting,
|
|
138
|
+
runtime,
|
|
139
|
+
isRuntimeLoading,
|
|
140
|
+
runtimeError
|
|
141
|
+
]);
|
|
142
|
+
const handleRetryRuntime = React.useCallback(() => {
|
|
143
|
+
setRuntime(null);
|
|
144
|
+
setRuntimeError(null);
|
|
145
|
+
}, []);
|
|
98
146
|
const ChartMap = useMemo(() => getChartMap(i18n), [i18n]);
|
|
99
147
|
const getAxisTitles = () => {
|
|
100
148
|
var _a, _b, _c, _d;
|
|
@@ -400,6 +448,111 @@ var ChartRender = (props) => {
|
|
|
400
448
|
)
|
|
401
449
|
);
|
|
402
450
|
}
|
|
451
|
+
if (chartType === "descriptions" || renderDescriptionsFallback) {
|
|
452
|
+
return /* @__PURE__ */ React.createElement(
|
|
453
|
+
"div",
|
|
454
|
+
{
|
|
455
|
+
key: config == null ? void 0 : config.index,
|
|
456
|
+
style: {
|
|
457
|
+
display: "flex",
|
|
458
|
+
flexDirection: "column",
|
|
459
|
+
gap: 8
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
chartData.map((row, rowIndex) => {
|
|
463
|
+
var _a2;
|
|
464
|
+
return /* @__PURE__ */ React.createElement(
|
|
465
|
+
Descriptions,
|
|
466
|
+
{
|
|
467
|
+
bordered: true,
|
|
468
|
+
key: `${config == null ? void 0 : config.index}-${rowIndex}`,
|
|
469
|
+
column: {
|
|
470
|
+
xxl: 2,
|
|
471
|
+
xl: 2,
|
|
472
|
+
lg: 2,
|
|
473
|
+
md: 2,
|
|
474
|
+
sm: 1,
|
|
475
|
+
xs: 1
|
|
476
|
+
},
|
|
477
|
+
items: (_a2 = config == null ? void 0 : config.columns) == null ? void 0 : _a2.map((column) => {
|
|
478
|
+
if (!column.title || !column.dataIndex)
|
|
479
|
+
return null;
|
|
480
|
+
return {
|
|
481
|
+
label: column.title || "",
|
|
482
|
+
children: row[column.dataIndex]
|
|
483
|
+
};
|
|
484
|
+
}).filter((item) => !!item)
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
})
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (!runtime && shouldLoadRuntime) {
|
|
491
|
+
const height = (config == null ? void 0 : config.height) || 240;
|
|
492
|
+
if (runtimeError) {
|
|
493
|
+
return /* @__PURE__ */ React.createElement(
|
|
494
|
+
"div",
|
|
495
|
+
{
|
|
496
|
+
style: {
|
|
497
|
+
minHeight: height,
|
|
498
|
+
display: "flex",
|
|
499
|
+
flexDirection: "column",
|
|
500
|
+
alignItems: "center",
|
|
501
|
+
justifyContent: "center",
|
|
502
|
+
width: "100%",
|
|
503
|
+
gap: 8,
|
|
504
|
+
color: "rgba(239, 68, 68, 0.8)"
|
|
505
|
+
},
|
|
506
|
+
role: "alert"
|
|
507
|
+
},
|
|
508
|
+
/* @__PURE__ */ React.createElement("span", null, runtimeError),
|
|
509
|
+
/* @__PURE__ */ React.createElement(
|
|
510
|
+
"button",
|
|
511
|
+
{
|
|
512
|
+
type: "button",
|
|
513
|
+
onClick: handleRetryRuntime,
|
|
514
|
+
style: {
|
|
515
|
+
padding: "4px 12px",
|
|
516
|
+
borderRadius: "0.5em",
|
|
517
|
+
border: "1px solid rgba(239, 68, 68, 0.5)",
|
|
518
|
+
background: "transparent",
|
|
519
|
+
color: "rgba(239, 68, 68, 0.8)",
|
|
520
|
+
cursor: "pointer"
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
"重试加载"
|
|
524
|
+
)
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
return /* @__PURE__ */ React.createElement(
|
|
528
|
+
"div",
|
|
529
|
+
{
|
|
530
|
+
style: {
|
|
531
|
+
minHeight: height,
|
|
532
|
+
display: "flex",
|
|
533
|
+
alignItems: "center",
|
|
534
|
+
justifyContent: "center",
|
|
535
|
+
width: "100%",
|
|
536
|
+
color: "#6B7280"
|
|
537
|
+
},
|
|
538
|
+
role: "status",
|
|
539
|
+
"aria-live": "polite"
|
|
540
|
+
},
|
|
541
|
+
isRuntimeLoading || !isIntersecting ? /* @__PURE__ */ React.createElement(Loading, null) : null
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (!runtime) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
const {
|
|
548
|
+
DonutChart,
|
|
549
|
+
FunnelChart,
|
|
550
|
+
AreaChart,
|
|
551
|
+
BarChart,
|
|
552
|
+
LineChart,
|
|
553
|
+
RadarChart,
|
|
554
|
+
ScatterChart
|
|
555
|
+
} = runtime;
|
|
403
556
|
if (chartType === "pie") {
|
|
404
557
|
return /* @__PURE__ */ React.createElement(
|
|
405
558
|
DonutChart,
|
|
@@ -563,48 +716,29 @@ var ChartRender = (props) => {
|
|
|
563
716
|
}
|
|
564
717
|
);
|
|
565
718
|
}
|
|
566
|
-
if (chartType === "descriptions" || chartData.length < 2 && (config == null ? void 0 : config.columns.length) > 8) {
|
|
567
|
-
return /* @__PURE__ */ React.createElement(
|
|
568
|
-
"div",
|
|
569
|
-
{
|
|
570
|
-
key: config == null ? void 0 : config.index,
|
|
571
|
-
style: {
|
|
572
|
-
display: "flex",
|
|
573
|
-
flexDirection: "column",
|
|
574
|
-
gap: 8
|
|
575
|
-
}
|
|
576
|
-
},
|
|
577
|
-
chartData.map((row) => {
|
|
578
|
-
return /* @__PURE__ */ React.createElement(
|
|
579
|
-
Descriptions,
|
|
580
|
-
{
|
|
581
|
-
bordered: true,
|
|
582
|
-
key: config == null ? void 0 : config.index,
|
|
583
|
-
column: {
|
|
584
|
-
xxl: 2,
|
|
585
|
-
xl: 2,
|
|
586
|
-
lg: 2,
|
|
587
|
-
md: 2,
|
|
588
|
-
sm: 1,
|
|
589
|
-
xs: 1
|
|
590
|
-
},
|
|
591
|
-
items: config == null ? void 0 : config.columns.map((column) => {
|
|
592
|
-
if (!column.title || !column.dataIndex)
|
|
593
|
-
return null;
|
|
594
|
-
return {
|
|
595
|
-
label: column.title || "",
|
|
596
|
-
children: row[column.dataIndex]
|
|
597
|
-
};
|
|
598
|
-
}).filter((item) => !!item)
|
|
599
|
-
}
|
|
600
|
-
);
|
|
601
|
-
})
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
}, [chartType, JSON.stringify(chartData), JSON.stringify(config)]);
|
|
605
|
-
if (!chartDom)
|
|
606
719
|
return null;
|
|
607
|
-
|
|
720
|
+
}, [
|
|
721
|
+
chartType,
|
|
722
|
+
JSON.stringify(chartData),
|
|
723
|
+
JSON.stringify(config),
|
|
724
|
+
renderKey,
|
|
725
|
+
toolBar,
|
|
726
|
+
convertDonutData,
|
|
727
|
+
convertFlatData,
|
|
728
|
+
title,
|
|
729
|
+
dataTime,
|
|
730
|
+
filterBy,
|
|
731
|
+
groupBy,
|
|
732
|
+
colorLegend,
|
|
733
|
+
runtime,
|
|
734
|
+
runtimeError,
|
|
735
|
+
isRuntimeLoading,
|
|
736
|
+
isIntersecting,
|
|
737
|
+
shouldLoadRuntime,
|
|
738
|
+
renderDescriptionsFallback,
|
|
739
|
+
handleRetryRuntime
|
|
740
|
+
]);
|
|
741
|
+
return /* @__PURE__ */ React.createElement("div", { ref: containerRef, style: { width: "100%" }, contentEditable: false }, chartDom);
|
|
608
742
|
};
|
|
609
743
|
export {
|
|
610
744
|
ChartRender
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
import LegendView from "./Legend";
|
|
63
63
|
import { createBackgroundArcPlugin, createCenterTextPlugin } from "./plugins";
|
|
64
64
|
import { useStyle } from "./style";
|
|
65
|
-
|
|
65
|
+
var donutChartComponentsRegistered = false;
|
|
66
66
|
var DonutChart = (_a) => {
|
|
67
67
|
var _b = _a, {
|
|
68
68
|
data,
|
|
@@ -102,6 +102,17 @@ var DonutChart = (_a) => {
|
|
|
102
102
|
"statistic"
|
|
103
103
|
]);
|
|
104
104
|
var _a2;
|
|
105
|
+
useMemo(() => {
|
|
106
|
+
if (donutChartComponentsRegistered) {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
if (typeof window === "undefined") {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
ChartJS.register(ArcElement, Tooltip, Legend);
|
|
113
|
+
donutChartComponentsRegistered = true;
|
|
114
|
+
return void 0;
|
|
115
|
+
}, []);
|
|
105
116
|
const { isMobile, windowWidth } = useMobile();
|
|
106
117
|
const defaultConfigs = [{ showLegend: true }];
|
|
107
118
|
const finalConfigs = configs || defaultConfigs;
|
|
@@ -44,6 +44,8 @@ export interface FunnelChartProps extends ChartContainerProps {
|
|
|
44
44
|
toolbarExtra?: React.ReactNode;
|
|
45
45
|
/** 是否将过滤器渲染到工具栏 */
|
|
46
46
|
renderFilterInToolbar?: boolean;
|
|
47
|
+
/** 最底层的最小宽度占比(0-1),相对于最顶层的宽度,0-不限制 */
|
|
48
|
+
bottomLayerMinWidth?: number;
|
|
47
49
|
/** ChartStatistic组件配置:object表示单个配置,array表示多个配置 */
|
|
48
50
|
statistic?: StatisticConfigType;
|
|
49
51
|
typeNames?: {
|