aldehyde 0.2.527 → 0.2.528
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/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.js +3 -3
- package/lib/controls/entity-select/entity-select.js.map +1 -1
- package/lib/controls/entity-select/index.css +6 -0
- package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +99 -99
- package/lib/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/lib/draw-canvas-edit/components/main-header/index.less +23 -23
- package/lib/icon/local-aliIcon/iconfont.js +1 -1
- package/lib/icon/local-aliIcon/iconfont.js.map +1 -1
- package/lib/lowcode-components/base-table/index.less +61 -61
- package/lib/lowcode-components/data-number/index.less +10 -10
- package/lib/lowcode-components/date-time/index.less +4 -4
- package/lib/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/lib/lowcode-components/heatmap-chart/index.d.ts +42 -0
- package/lib/lowcode-components/heatmap-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/heatmap-chart/index.js +326 -0
- package/lib/lowcode-components/heatmap-chart/index.js.map +1 -0
- package/lib/lowcode-components/index.d.ts +2 -0
- package/lib/lowcode-components/index.d.ts.map +1 -1
- package/lib/lowcode-components/index.js +2 -1
- package/lib/lowcode-components/index.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/assets.js +8 -0
- package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/lib/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/lib/lowcode-components/text-scroller/index.less +28 -28
- package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-card.js +2 -6
- package/lib/module/dtmpl-edit-card.js.map +1 -1
- package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-page.js +2 -6
- package/lib/module/dtmpl-edit-page.js.map +1 -1
- package/lib/module/ttmpl-table.d.ts +3 -0
- package/lib/module/ttmpl-table.d.ts.map +1 -1
- package/lib/module/ttmpl-table.js +15 -8
- package/lib/module/ttmpl-table.js.map +1 -1
- package/lib/routable/ttmpl-table-route.d.ts.map +1 -1
- package/lib/routable/ttmpl-table-route.js +32 -7
- package/lib/routable/ttmpl-table-route.js.map +1 -1
- package/lib/table/act-table.d.ts +1 -0
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +2 -2
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/column/column-builder.d.ts.map +1 -1
- package/lib/table/column/column-builder.js +20 -4
- package/lib/table/column/column-builder.js.map +1 -1
- package/lib/table/relation-table.js +1 -1
- package/lib/table/relation-table.js.map +1 -1
- package/lib/tmpl/hc-data-source.d.ts +1 -0
- package/lib/tmpl/hc-data-source.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.js +11 -0
- package/lib/tmpl/hc-data-source.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts +1 -0
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js +12 -0
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/interface.d.ts +7 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/entity-select/entity-select.tsx +4 -5
- package/src/aldehyde/controls/entity-select/index.css +6 -0
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +99 -99
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +156 -156
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +110 -110
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.less +23 -23
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +263 -263
- package/src/aldehyde/draw-canvas-edit/components/render/draws/index.ts +7 -7
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +241 -241
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +699 -699
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +500 -500
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/index.ts +5 -5
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +493 -493
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +680 -680
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +68 -68
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +113 -113
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/index.ts +9 -9
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +49 -49
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +81 -81
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +59 -59
- package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +89 -89
- package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +154 -154
- package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +222 -222
- package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +224 -224
- package/src/aldehyde/draw-canvas-edit/components/render/utils/a-star.ts +116 -116
- package/src/aldehyde/draw-canvas-edit/components/render/utils/bezier-scene-func.ts +72 -72
- package/src/aldehyde/draw-canvas-edit/components/setting-form/imag-upload.tsx +119 -119
- package/src/aldehyde/icon/local-aliIcon/iconfont.js +1 -1
- package/src/aldehyde/layout4/imgs/user.svg +26 -26
- package/src/aldehyde/lowcode-components/base-color-block/index.tsx +31 -31
- package/src/aldehyde/lowcode-components/base-table/index.less +61 -61
- package/src/aldehyde/lowcode-components/data-number/index.less +10 -10
- package/src/aldehyde/lowcode-components/date-time/index.less +4 -4
- package/src/aldehyde/lowcode-components/date-time/index.tsx +64 -64
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -53
- package/src/aldehyde/lowcode-components/heatmap-chart/index.tsx +362 -0
- package/src/aldehyde/lowcode-components/index.ts +4 -2
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -64
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -77
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +8 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +144 -144
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +53 -53
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +15 -15
- package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +98 -98
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +121 -121
- package/src/aldehyde/lowcode-components/placeholder-component/index.tsx +81 -81
- package/src/aldehyde/lowcode-components/text-scroller/index.less +28 -28
- package/src/aldehyde/lowcode-components/text-scroller/index.tsx +173 -173
- package/src/aldehyde/module/dtmpl-edit-card.tsx +2 -6
- package/src/aldehyde/module/dtmpl-edit-page.tsx +2 -6
- package/src/aldehyde/module/ttmpl-table.tsx +25 -7
- package/src/aldehyde/routable/ttmpl-table-route.tsx +37 -7
- package/src/aldehyde/table/act-table.tsx +4 -2
- package/src/aldehyde/table/column/column-builder.tsx +30 -5
- package/src/aldehyde/table/relation-table.tsx +1 -1
- package/src/aldehyde/tmpl/hc-data-source.tsx +11 -0
- package/src/aldehyde/tmpl/hcservice-v3.tsx +11 -0
- package/src/aldehyde/tmpl/interface.tsx +3 -1
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import * as echarts from 'echarts';
|
|
2
|
+
import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { Spin } from "antd";
|
|
5
|
+
import { useLocale } from "../../locale/useLocale";
|
|
6
|
+
import HydrocarbonService from "../../tmpl/hcservice-v3";
|
|
7
|
+
import { DataConfigProps } from "../data";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 热力图组件
|
|
11
|
+
* x轴:维度1(d1)
|
|
12
|
+
* y轴:维度2(d2)
|
|
13
|
+
* 数值:事实1(v1)
|
|
14
|
+
* 状态-颜色:事实2(v2)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const defData = [
|
|
18
|
+
['01', 'A', 0],
|
|
19
|
+
['02', 'A', 0],
|
|
20
|
+
['03', 'A', 0],
|
|
21
|
+
['04', 'A', 2.3],
|
|
22
|
+
['05', 'A', 3.5],
|
|
23
|
+
['06', 'A', 0],
|
|
24
|
+
['01', 'B', 2.820],
|
|
25
|
+
['02', 'B', 2.950],
|
|
26
|
+
['03', 'B', 0],
|
|
27
|
+
['04', 'B', 3.620],
|
|
28
|
+
['05', 'B', 3.710],
|
|
29
|
+
['06', 'B', 4.650],
|
|
30
|
+
['01', 'C', 3.210],
|
|
31
|
+
['02', 'C', 3.350],
|
|
32
|
+
['03', 'C', 3.660],
|
|
33
|
+
['04', 'C', 0],
|
|
34
|
+
['05', 'C', 3.920],
|
|
35
|
+
['06', 'C', 4.100],
|
|
36
|
+
['01', 'D', 4.600],
|
|
37
|
+
['02', 'D', 4.750],
|
|
38
|
+
['03', 'D', 3.910],
|
|
39
|
+
['04', 'D', 3.820],
|
|
40
|
+
['05', 'D', 0],
|
|
41
|
+
['06', 'D', 3.640]
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const defVisualMap: any = {// 默认分段视觉映射
|
|
45
|
+
show: false,
|
|
46
|
+
type: 'piecewise',
|
|
47
|
+
left: 'left',
|
|
48
|
+
bottom: '5%',
|
|
49
|
+
textStyle: { color: '#fff' },
|
|
50
|
+
pieces: [
|
|
51
|
+
{ min: 0, max: 0, color: '#666e7f', label: '停工无生产' },
|
|
52
|
+
{ min: 0.001, lt: 3.5, color: '#00c878', label: '优(<3.5)' },
|
|
53
|
+
{ min: 3.5, lt: 4.5, color: '#ffd040', label: '良(3.5~4.5)' },
|
|
54
|
+
{ min: 4.5, color: '#ff3b30', label: '差(≥4.5)' }
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const defOption = {
|
|
59
|
+
title: {
|
|
60
|
+
text: '暂无数据',
|
|
61
|
+
left: 'center',
|
|
62
|
+
top: 'middle',
|
|
63
|
+
show: false, // 无数据时显示
|
|
64
|
+
},
|
|
65
|
+
tooltip: { trigger: "axis", formatter: undefined },
|
|
66
|
+
grid: { top: 30, left: 30, right: 20, bottom: 30 },
|
|
67
|
+
visualMap: { // 分段视觉映射
|
|
68
|
+
show: false
|
|
69
|
+
},
|
|
70
|
+
xAxis: {
|
|
71
|
+
type: 'category',
|
|
72
|
+
data: ['01', '02', '03', '04', '05', '06'],
|
|
73
|
+
},
|
|
74
|
+
yAxis: {
|
|
75
|
+
type: 'category',
|
|
76
|
+
data: ['A', 'B', 'C', 'D'],
|
|
77
|
+
},
|
|
78
|
+
series: [
|
|
79
|
+
{
|
|
80
|
+
type: 'heatmap',
|
|
81
|
+
data: defData,
|
|
82
|
+
itemStyle: {
|
|
83
|
+
borderColor: '#aaaaaa',
|
|
84
|
+
borderWidth: 1
|
|
85
|
+
},
|
|
86
|
+
label: {
|
|
87
|
+
show: true,
|
|
88
|
+
color: '#fff',
|
|
89
|
+
fontSize: 9,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// 处理关系字段显示
|
|
96
|
+
const handleRelationVal = (val: string) => {
|
|
97
|
+
if (!val) {
|
|
98
|
+
return val;
|
|
99
|
+
}
|
|
100
|
+
if (typeof val === "string" && val?.includes("@R@")) {
|
|
101
|
+
return val.split("@R@")[1];
|
|
102
|
+
} else {
|
|
103
|
+
return val;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 处理数据格式
|
|
108
|
+
const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
|
|
109
|
+
if (!data?.length) {
|
|
110
|
+
return { xAxisData: [], yAxisData: [], data: [] };
|
|
111
|
+
}
|
|
112
|
+
const temData = data.map((r) => {
|
|
113
|
+
const { config, value } = r;
|
|
114
|
+
// 维度字段 (d1、d2等)
|
|
115
|
+
const dNames = Object.keys(config).filter((r) => r.startsWith("d") && !r.includes("-")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
|
|
116
|
+
// 事实字段 (v1、v2等) v1数值,v2颜色
|
|
117
|
+
const vNames = Object.keys(config).filter((r) => r.startsWith("v") && !r.includes("-")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
|
|
118
|
+
return value.map((r) => ({ value: [handleRelationVal(r["d1"]), handleRelationVal(r["d2"]), r["v1"]], itemStyle: { color: r["v2-color"] }, otherData: [...dNames.map(v => ({ name: config[v], value: handleRelationVal(r[v]), key: v })), ...vNames.map(v => ({ name: config[v], value: r[v], key: v, color: r[v + "-color"] }))] }));
|
|
119
|
+
});
|
|
120
|
+
let xAxisData = [], yAxisData = [];
|
|
121
|
+
temData[0].forEach((r) => {
|
|
122
|
+
if (!xAxisData.includes(r.value[0])) xAxisData.push(r.value[0]);
|
|
123
|
+
if (!yAxisData.includes(r.value[1])) yAxisData.push(r.value[1]);
|
|
124
|
+
});
|
|
125
|
+
return { xAxisData, yAxisData, data: temData[0] };
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export interface ComponentStyle {
|
|
129
|
+
tooltip?: { show: boolean };
|
|
130
|
+
grid?: { top: number, left: number, right: number, bottom: number };
|
|
131
|
+
xAxis?: { [key: string]: any };
|
|
132
|
+
yAxis?: { [key: string]: any };
|
|
133
|
+
renderer?: "canvas" | "svg";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ComponentProps {
|
|
137
|
+
style?: ComponentStyle;
|
|
138
|
+
base?: { width: number, height: number };
|
|
139
|
+
data?: DataConfigProps;
|
|
140
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
141
|
+
initSearchParams?: { [key: string]: any }; // 全局初始化外部参数,例:传参包含设备id,则在查询时带上设备id
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ComponentRef {
|
|
145
|
+
updateConfig: (newConfig: ComponentProps) => void;
|
|
146
|
+
destroy: () => void;
|
|
147
|
+
updateSearchParams: (params: { [key: string]: any }) => void;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
151
|
+
const { style, data: propsData, isDesignMode } = props;
|
|
152
|
+
const [config, setConfig] = useState<ComponentStyle>(style || {});
|
|
153
|
+
const [renderType, setRenderType] = useState<"canvas" | "svg">(style?.renderer || "svg"); // 渲染模式
|
|
154
|
+
const [size, setSize] = useState<{ width: number, height: number }>();
|
|
155
|
+
const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
|
|
156
|
+
const [data, setData] = useState<{ [key: string]: any }[]>([]);
|
|
157
|
+
const [xAxisData, setXAxisData] = useState<string[]>([]);
|
|
158
|
+
const [yAxisData, setYAxisData] = useState<string[]>([]);
|
|
159
|
+
const [searchParams, setSearchParams] = useState<{ [key: string]: any }>();
|
|
160
|
+
const [initSearchParams, setInitSearchParams] = useState<{ [key: string]: any }>();
|
|
161
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
162
|
+
const chartRef = useRef<HTMLDivElement>(null);
|
|
163
|
+
const chart = useRef<any>(null);
|
|
164
|
+
const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
|
|
165
|
+
const resizeObserverRef = useRef<any>(null);
|
|
166
|
+
const { translate } = useLocale();
|
|
167
|
+
|
|
168
|
+
const handleDestroy = () => {
|
|
169
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
170
|
+
resizeObserverRef.current && resizeObserverRef.current.disconnect();
|
|
171
|
+
chart.current && chart.current.dispose();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// 全局初始化请求数据处理
|
|
175
|
+
const handleInitData = (val: DataConfigProps) => {
|
|
176
|
+
if (val.sourceType === "sourceId" && val.isInit && val.initData) {
|
|
177
|
+
const { config: dataConfig, value } = val.initData;
|
|
178
|
+
const temData = handleData(value);
|
|
179
|
+
setData(temData.data || []);
|
|
180
|
+
setXAxisData(temData.xAxisData || []);
|
|
181
|
+
setYAxisData(temData.yAxisData || []);
|
|
182
|
+
if (dataConfig?.requestMode === "polling") {
|
|
183
|
+
pollingIntervalRef.current = setInterval(() => { getData() }, dataConfig?.pollingInterval || 60000);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ws订阅数据更新
|
|
189
|
+
const handleWSData = (val: DataConfigProps) => {
|
|
190
|
+
if (val.sourceType === "sourceId" && val.wsData) {
|
|
191
|
+
const { value } = val.initData;
|
|
192
|
+
const temData = handleData(value);
|
|
193
|
+
setData(temData.data || []);
|
|
194
|
+
setXAxisData(temData.xAxisData || []);
|
|
195
|
+
setYAxisData(temData.yAxisData || []);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
useImperativeHandle(ref, () => ({
|
|
200
|
+
updateConfig: (newConfig) => {
|
|
201
|
+
const { base, style: newStyle, data: newDataConfig, initSearchParams: newISParams } = newConfig;
|
|
202
|
+
setConfig({ ...(newStyle || {}) });
|
|
203
|
+
setSize({ width: base.width, height: base.height });
|
|
204
|
+
setDataConfig(newDataConfig);
|
|
205
|
+
setRenderType(newStyle?.renderer || "svg");
|
|
206
|
+
handleInitData(newDataConfig);
|
|
207
|
+
setSearchParams(newDataConfig.searchParams);
|
|
208
|
+
setInitSearchParams(newISParams);
|
|
209
|
+
handleWSData(newDataConfig);
|
|
210
|
+
},
|
|
211
|
+
updateSearchParams: (params) => {
|
|
212
|
+
setInitSearchParams(params);
|
|
213
|
+
},
|
|
214
|
+
destroy: handleDestroy,
|
|
215
|
+
}));
|
|
216
|
+
|
|
217
|
+
// 窗口大小变化时重新调整图表大小
|
|
218
|
+
const handleResize = () => {
|
|
219
|
+
const container = chartRef.current;
|
|
220
|
+
if (!container || container.offsetWidth === 0 || container.offsetHeight === 0) return;
|
|
221
|
+
if (chart.current) {
|
|
222
|
+
requestAnimationFrame(() => {
|
|
223
|
+
chart.current.resize({ animation: { duration: 500 } });
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
return () => {
|
|
230
|
+
handleDestroy();
|
|
231
|
+
}
|
|
232
|
+
}, []);
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
handleDestroy();
|
|
236
|
+
chart.current = echarts.init(chartRef.current, null, { renderer: renderType, useDirtyRect: true });
|
|
237
|
+
// 监听容器尺寸变化:页面从隐藏(如切到其他 tab)变为可见时,图表自动重新适应
|
|
238
|
+
resizeObserverRef.current = new ResizeObserver(() => handleResize());
|
|
239
|
+
resizeObserverRef.current.observe(chartRef.current);
|
|
240
|
+
}, [renderType]);
|
|
241
|
+
|
|
242
|
+
// 请求数据
|
|
243
|
+
const getData = async (params?: object) => {
|
|
244
|
+
setLoading(true);
|
|
245
|
+
const { data } = await HydrocarbonService.requestChartData(null, dataConfig?.sourceId, params) || {};
|
|
246
|
+
setLoading(false);
|
|
247
|
+
const temData = handleData(data?.value);
|
|
248
|
+
setData(temData.data || []);
|
|
249
|
+
setXAxisData(temData.xAxisData || []);
|
|
250
|
+
setYAxisData(temData.yAxisData || []);
|
|
251
|
+
return data?.config;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// 初始化请求数据
|
|
255
|
+
const getInitData = async (params?: object) => {
|
|
256
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
257
|
+
const config = await getData(params);
|
|
258
|
+
if (config?.requestMode === "polling") {
|
|
259
|
+
pollingIntervalRef.current = setInterval(() => getData(params), config?.pollingInterval || 60000);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// 静态数据处理
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (dataConfig?.sourceType === 'staticData') {
|
|
266
|
+
const temData = handleData(dataConfig.staticData);
|
|
267
|
+
setData(temData.data || []);
|
|
268
|
+
setXAxisData(temData.xAxisData || []);
|
|
269
|
+
setYAxisData(temData.yAxisData || []);
|
|
270
|
+
}
|
|
271
|
+
}, [dataConfig?.sourceType, dataConfig?.staticData]);
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 数据源数据请求
|
|
275
|
+
* 1、编辑态不请求数据
|
|
276
|
+
*/
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId && !dataConfig?.isInit && dataConfig?.isDefRequest !== false) {
|
|
279
|
+
if (dataConfig?.isInitParams) { // 组件数据源接收外部参数
|
|
280
|
+
initSearchParams && getInitData(initSearchParams);
|
|
281
|
+
} else {
|
|
282
|
+
getInitData();
|
|
283
|
+
}
|
|
284
|
+
} else if (dataConfig?.sourceType === 'sourceId') {
|
|
285
|
+
setData([]);
|
|
286
|
+
}
|
|
287
|
+
}, [dataConfig?.sourceType, dataConfig?.sourceId, initSearchParams]);
|
|
288
|
+
|
|
289
|
+
// 搜索参数变化时重新请求数据
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (searchParams) {
|
|
292
|
+
const params = { ...(initSearchParams || {}), ...searchParams };
|
|
293
|
+
if (dataConfig?.isInitParams) { // 数据源接收外部参数,则参数存在再请求
|
|
294
|
+
initSearchParams && getInitData(params);
|
|
295
|
+
} else {
|
|
296
|
+
getInitData(params);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, [searchParams, initSearchParams]);
|
|
300
|
+
|
|
301
|
+
const renderChart = (tData) => {
|
|
302
|
+
const { grid, tooltip, xAxis, yAxis } = config;
|
|
303
|
+
const option = _.cloneDeep(defOption);
|
|
304
|
+
const isDefaultData = isDesignMode && !tData?.length;
|
|
305
|
+
// 编辑态无数据显示默认数据
|
|
306
|
+
const temData = isDefaultData ? defData : tData;
|
|
307
|
+
option.grid = grid;
|
|
308
|
+
option.tooltip = {
|
|
309
|
+
trigger: "axis",
|
|
310
|
+
...tooltip,
|
|
311
|
+
formatter: (params) => {
|
|
312
|
+
const temData = params[0]?.data?.otherData || [];
|
|
313
|
+
if (!temData?.length) {
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
return temData.map(item => `<div style="margin-bottom: 6px;"><span style="font-weight: bold;font-size: 15px;">${item.name}</span>:<span style=${item.color ? `color:${item.color}` : ""}>${item.value}</span></div>`).join('');
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
option.xAxis = { ...option.xAxis, ...xAxis, data: isDefaultData ? option.xAxis.data : xAxisData || [] };
|
|
320
|
+
option.yAxis = { ...option.yAxis, ...yAxis, data: isDefaultData ? option.yAxis.data : yAxisData || [] };
|
|
321
|
+
option.title.text = translate("${暂无数据}");
|
|
322
|
+
option.title.show = !temData?.length;
|
|
323
|
+
option.visualMap = isDefaultData ? defVisualMap : { show: false };
|
|
324
|
+
option.series = [{
|
|
325
|
+
type: "heatmap",
|
|
326
|
+
data: temData,
|
|
327
|
+
itemStyle: {
|
|
328
|
+
borderColor: "#000",
|
|
329
|
+
borderWidth: 1,
|
|
330
|
+
},
|
|
331
|
+
label: {
|
|
332
|
+
show: true,
|
|
333
|
+
color: "#fff",
|
|
334
|
+
fontSize: 12,
|
|
335
|
+
},
|
|
336
|
+
}];
|
|
337
|
+
chart.current.setOption(option, true);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
if (config) {
|
|
342
|
+
renderChart(data);
|
|
343
|
+
}
|
|
344
|
+
}, [config, data]);
|
|
345
|
+
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
if (size) {
|
|
348
|
+
handleResize();
|
|
349
|
+
}
|
|
350
|
+
}, [size]);
|
|
351
|
+
|
|
352
|
+
const renderChartDom = () => <div ref={chartRef} style={{ width: '100%', height: '100%' }} />;
|
|
353
|
+
|
|
354
|
+
if (isDesignMode) {
|
|
355
|
+
return renderChartDom();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return <Spin spinning={loading}>{renderChartDom()}</Spin>;
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
export default Index;
|
|
362
|
+
|
|
@@ -54,6 +54,7 @@ import Carousel from "./carousel";
|
|
|
54
54
|
import SearchForm from "./search-form";
|
|
55
55
|
import BaseRadio from "./base-radio";
|
|
56
56
|
import RadarChart from "./radar-chart";
|
|
57
|
+
import HeatmapChart from "./heatmap-chart";
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
type CompoundedComponent = {
|
|
@@ -112,7 +113,8 @@ type CompoundedComponent = {
|
|
|
112
113
|
Carousel?: typeof Carousel,
|
|
113
114
|
SearchForm?: typeof SearchForm,
|
|
114
115
|
BaseRadio?: typeof BaseRadio,
|
|
115
|
-
RadarChart?: typeof RadarChart
|
|
116
|
+
RadarChart?: typeof RadarChart,
|
|
117
|
+
HeatmapChart?: typeof HeatmapChart,
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
const LowcodeComponents: CompoundedComponent = {
|
|
@@ -125,7 +127,7 @@ const LowcodeComponents: CompoundedComponent = {
|
|
|
125
127
|
Decoration6, Decoration7, Decoration8, Decoration9, Decoration10, Decoration11,
|
|
126
128
|
BaseTable, TextScroller, CapsuleBarChart, CircularProgressChart, ActTable, ProgressChart,
|
|
127
129
|
LineBarChart, Column3dChart, StrokeAnimation, EffectScatterMap3D, BaseButton, BaseTabs,
|
|
128
|
-
PlaceholderComponent, Carousel, SearchForm, BaseRadio, RadarChart
|
|
130
|
+
PlaceholderComponent, Carousel, SearchForm, BaseRadio, RadarChart, HeatmapChart
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
export default LowcodeComponents;
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
export interface UpdateOptions {
|
|
2
|
-
reRender: boolean;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 设计器自定义组件控制器的顶级抽象接口,用于控制自定义组件的整个生命周期
|
|
7
|
-
* @param I 组件实例类型,若组件为React的class组件,则I=class的实例化对象。
|
|
8
|
-
* 若组件为React的函数式组件,则I=forwardRef钩子传递出的ref引用(当然你也可以有其他自定义的实现)
|
|
9
|
-
* 若组件为纯Js实现的组件,则I=组件实例化对象(可参考Echarts活G2创建实例后的返回值)
|
|
10
|
-
* @param C 组件配置类型,即组件的完整属性类型
|
|
11
|
-
*/
|
|
12
|
-
abstract class AbstractController<I = any, C = any> {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 组件实例引用
|
|
16
|
-
* @protected
|
|
17
|
-
*/
|
|
18
|
-
protected instance: I | null = null;
|
|
19
|
-
/**
|
|
20
|
-
* 组件配置(包括组件数据)
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
public config: C | null = null;
|
|
24
|
-
/**
|
|
25
|
-
* 组件所处容器的dom元素
|
|
26
|
-
* @protected
|
|
27
|
-
*/
|
|
28
|
-
public container: HTMLElement | null = null;
|
|
29
|
-
|
|
30
|
-
/******************生命周期******************/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 创建组件并将组件挂载到指定的容器中
|
|
34
|
-
* @param container 容器
|
|
35
|
-
* @param config 组件配置
|
|
36
|
-
*/
|
|
37
|
-
public abstract create(container: HTMLElement, config: C): Promise<void>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 更新组件配置,并触发组件重新渲染
|
|
41
|
-
* @param config 组件属性(参数)
|
|
42
|
-
* @param upOp 操作类型
|
|
43
|
-
*/
|
|
44
|
-
public abstract update(config: C, upOp?: UpdateOptions): void;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 销毁组件
|
|
48
|
-
*/
|
|
49
|
-
public destroy(): void {
|
|
50
|
-
this.instance = null;
|
|
51
|
-
this.config = null;
|
|
52
|
-
this.container = null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/******************普通方法******************/
|
|
57
|
-
/**
|
|
58
|
-
* 获取组件配置数据
|
|
59
|
-
*/
|
|
60
|
-
public abstract getConfig(): C | null;
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default AbstractController;
|
|
1
|
+
export interface UpdateOptions {
|
|
2
|
+
reRender: boolean;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 设计器自定义组件控制器的顶级抽象接口,用于控制自定义组件的整个生命周期
|
|
7
|
+
* @param I 组件实例类型,若组件为React的class组件,则I=class的实例化对象。
|
|
8
|
+
* 若组件为React的函数式组件,则I=forwardRef钩子传递出的ref引用(当然你也可以有其他自定义的实现)
|
|
9
|
+
* 若组件为纯Js实现的组件,则I=组件实例化对象(可参考Echarts活G2创建实例后的返回值)
|
|
10
|
+
* @param C 组件配置类型,即组件的完整属性类型
|
|
11
|
+
*/
|
|
12
|
+
abstract class AbstractController<I = any, C = any> {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 组件实例引用
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected instance: I | null = null;
|
|
19
|
+
/**
|
|
20
|
+
* 组件配置(包括组件数据)
|
|
21
|
+
* @protected
|
|
22
|
+
*/
|
|
23
|
+
public config: C | null = null;
|
|
24
|
+
/**
|
|
25
|
+
* 组件所处容器的dom元素
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
28
|
+
public container: HTMLElement | null = null;
|
|
29
|
+
|
|
30
|
+
/******************生命周期******************/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 创建组件并将组件挂载到指定的容器中
|
|
34
|
+
* @param container 容器
|
|
35
|
+
* @param config 组件配置
|
|
36
|
+
*/
|
|
37
|
+
public abstract create(container: HTMLElement, config: C): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 更新组件配置,并触发组件重新渲染
|
|
41
|
+
* @param config 组件属性(参数)
|
|
42
|
+
* @param upOp 操作类型
|
|
43
|
+
*/
|
|
44
|
+
public abstract update(config: C, upOp?: UpdateOptions): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 销毁组件
|
|
48
|
+
*/
|
|
49
|
+
public destroy(): void {
|
|
50
|
+
this.instance = null;
|
|
51
|
+
this.config = null;
|
|
52
|
+
this.container = null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/******************普通方法******************/
|
|
57
|
+
/**
|
|
58
|
+
* 获取组件配置数据
|
|
59
|
+
*/
|
|
60
|
+
public abstract getConfig(): C | null;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default AbstractController;
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import AbstractController from "./abstract-controller";
|
|
2
|
-
import React, { ComponentType } from "react";
|
|
3
|
-
import ComponentController from "./component-controller";
|
|
4
|
-
|
|
5
|
-
export type ClazzTemplate<C> = new () => C | null;
|
|
6
|
-
|
|
7
|
-
export interface ActionInfo {
|
|
8
|
-
name: string;
|
|
9
|
-
id: string;
|
|
10
|
-
handler: (controller: ComponentController, params?: any) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ICategorize {
|
|
14
|
-
key: string;
|
|
15
|
-
name: string;
|
|
16
|
-
icon?: ComponentType;
|
|
17
|
-
parentKey?: string;
|
|
18
|
-
iconType?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 组件基础信息
|
|
23
|
-
*/
|
|
24
|
-
export interface BaseInfoType {
|
|
25
|
-
/**
|
|
26
|
-
* 组件显示名称
|
|
27
|
-
*/
|
|
28
|
-
compName: string;
|
|
29
|
-
/**
|
|
30
|
-
* 组件标识
|
|
31
|
-
*/
|
|
32
|
-
compKey: string;
|
|
33
|
-
/**
|
|
34
|
-
* 主分类
|
|
35
|
-
*/
|
|
36
|
-
categorize?: string;
|
|
37
|
-
/**
|
|
38
|
-
* 子分类
|
|
39
|
-
*/
|
|
40
|
-
subCategorize?: string;
|
|
41
|
-
/**
|
|
42
|
-
* 版本
|
|
43
|
-
*/
|
|
44
|
-
version?: string;
|
|
45
|
-
/**
|
|
46
|
-
* 初始宽度
|
|
47
|
-
*/
|
|
48
|
-
width?: number;
|
|
49
|
-
/**
|
|
50
|
-
* 初始高度
|
|
51
|
-
*/
|
|
52
|
-
height?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 自动扫描抽象组件定义核心类。
|
|
57
|
-
* 对于所有继承并实现了该抽象类的子类,都会被自动扫描到并注册到设计器中。
|
|
58
|
-
* 因此,所有要接入设计器的react组件都应该按照该类的约定实现其所有的方法。
|
|
59
|
-
*
|
|
60
|
-
* 泛型说明:
|
|
61
|
-
* C: 组件控制器类,用于指定当前组件定义对应的控制器类
|
|
62
|
-
* P: 组件配置类型,用于指定当前组件的配置数据(config属性的类型)
|
|
63
|
-
*/
|
|
64
|
-
export abstract class AbstractDefinition<C extends AbstractController = AbstractController, P = any> {
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 返回组件基础信息,用于在组件列表中展示
|
|
68
|
-
*/
|
|
69
|
-
abstract getBaseInfo(): BaseInfoType;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 返回React组件Controller控制器的类模板,在画布中创建组件实例时会根据该方法的返回值实例化组件控制器并保存。
|
|
73
|
-
* 后续将通过该控制器的实例对象来控制组件的生命周期
|
|
74
|
-
*/
|
|
75
|
-
abstract getController(): ClazzTemplate<C> | null;
|
|
76
|
-
}
|
|
77
|
-
|
|
1
|
+
import AbstractController from "./abstract-controller";
|
|
2
|
+
import React, { ComponentType } from "react";
|
|
3
|
+
import ComponentController from "./component-controller";
|
|
4
|
+
|
|
5
|
+
export type ClazzTemplate<C> = new () => C | null;
|
|
6
|
+
|
|
7
|
+
export interface ActionInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
handler: (controller: ComponentController, params?: any) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ICategorize {
|
|
14
|
+
key: string;
|
|
15
|
+
name: string;
|
|
16
|
+
icon?: ComponentType;
|
|
17
|
+
parentKey?: string;
|
|
18
|
+
iconType?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 组件基础信息
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseInfoType {
|
|
25
|
+
/**
|
|
26
|
+
* 组件显示名称
|
|
27
|
+
*/
|
|
28
|
+
compName: string;
|
|
29
|
+
/**
|
|
30
|
+
* 组件标识
|
|
31
|
+
*/
|
|
32
|
+
compKey: string;
|
|
33
|
+
/**
|
|
34
|
+
* 主分类
|
|
35
|
+
*/
|
|
36
|
+
categorize?: string;
|
|
37
|
+
/**
|
|
38
|
+
* 子分类
|
|
39
|
+
*/
|
|
40
|
+
subCategorize?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 版本
|
|
43
|
+
*/
|
|
44
|
+
version?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 初始宽度
|
|
47
|
+
*/
|
|
48
|
+
width?: number;
|
|
49
|
+
/**
|
|
50
|
+
* 初始高度
|
|
51
|
+
*/
|
|
52
|
+
height?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 自动扫描抽象组件定义核心类。
|
|
57
|
+
* 对于所有继承并实现了该抽象类的子类,都会被自动扫描到并注册到设计器中。
|
|
58
|
+
* 因此,所有要接入设计器的react组件都应该按照该类的约定实现其所有的方法。
|
|
59
|
+
*
|
|
60
|
+
* 泛型说明:
|
|
61
|
+
* C: 组件控制器类,用于指定当前组件定义对应的控制器类
|
|
62
|
+
* P: 组件配置类型,用于指定当前组件的配置数据(config属性的类型)
|
|
63
|
+
*/
|
|
64
|
+
export abstract class AbstractDefinition<C extends AbstractController = AbstractController, P = any> {
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 返回组件基础信息,用于在组件列表中展示
|
|
68
|
+
*/
|
|
69
|
+
abstract getBaseInfo(): BaseInfoType;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 返回React组件Controller控制器的类模板,在画布中创建组件实例时会根据该方法的返回值实例化组件控制器并保存。
|
|
73
|
+
* 后续将通过该控制器的实例对象来控制组件的生命周期
|
|
74
|
+
*/
|
|
75
|
+
abstract getController(): ClazzTemplate<C> | null;
|
|
76
|
+
}
|
|
77
|
+
|