aldehyde 0.2.296 → 0.2.299
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/action/index.d.ts.map +1 -1
- package/lib/controls/action/index.js +1 -1
- package/lib/controls/action/index.js.map +1 -1
- package/lib/controls/action/utils.d.ts.map +1 -1
- package/lib/controls/action/utils.js +1 -1
- package/lib/controls/action/utils.js.map +1 -1
- package/lib/detail/edit/fields-edit-card.d.ts +2 -0
- package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/fields-edit-card.js +4 -3
- package/lib/detail/edit/fields-edit-card.js.map +1 -1
- package/lib/detail/edit/{row-edit-card.d.ts → popover-edit-card.d.ts} +2 -2
- package/lib/detail/edit/popover-edit-card.d.ts.map +1 -0
- package/lib/detail/edit/{row-edit-card.js → popover-edit-card.js} +5 -5
- package/lib/detail/edit/popover-edit-card.js.map +1 -0
- package/lib/detail/edit/{row-editor.d.ts → popover-editor.d.ts} +2 -2
- package/lib/detail/edit/popover-editor.d.ts.map +1 -0
- package/lib/detail/edit/{row-editor.js → popover-editor.js} +6 -6
- package/lib/detail/edit/popover-editor.js.map +1 -0
- package/lib/form/criteria-form.js +1 -1
- package/lib/form/criteria-form.js.map +1 -1
- package/lib/form/fields-form.d.ts +1 -0
- package/lib/form/fields-form.d.ts.map +1 -1
- package/lib/form/fields-form.js +2 -2
- package/lib/form/fields-form.js.map +1 -1
- package/lib/layout/menu/user-bar.d.ts.map +1 -1
- package/lib/layout/menu/user-bar.js +2 -1
- package/lib/layout/menu/user-bar.js.map +1 -1
- package/lib/layout2/components/user-button.d.ts.map +1 -1
- package/lib/layout2/components/user-button.js +2 -1
- package/lib/layout2/components/user-button.js.map +1 -1
- package/lib/lowcode-components/assets/china.json +1 -1
- package/lib/lowcode-components/column-3d-chart/index.d.ts +43 -0
- package/lib/lowcode-components/column-3d-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/column-3d-chart/index.js +342 -0
- package/lib/lowcode-components/column-3d-chart/index.js.map +1 -0
- package/lib/lowcode-components/effectScatter-map-3d/index.d.ts +34 -0
- package/lib/lowcode-components/effectScatter-map-3d/index.d.ts.map +1 -0
- package/lib/lowcode-components/effectScatter-map-3d/index.js +273 -0
- package/lib/lowcode-components/effectScatter-map-3d/index.js.map +1 -0
- package/lib/lowcode-components/gauge-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/gauge-chart/index.js +19 -16
- package/lib/lowcode-components/gauge-chart/index.js.map +1 -1
- package/lib/lowcode-components/index.d.ts +8 -0
- package/lib/lowcode-components/index.d.ts.map +1 -1
- package/lib/lowcode-components/index.js +6 -1
- package/lib/lowcode-components/index.js.map +1 -1
- package/lib/lowcode-components/line-bar-chart/index.d.ts +57 -0
- package/lib/lowcode-components/line-bar-chart/index.d.ts.map +1 -0
- package/lib/lowcode-components/line-bar-chart/index.js +178 -0
- package/lib/lowcode-components/line-bar-chart/index.js.map +1 -0
- package/lib/lowcode-components/line-chart/index.d.ts +1 -0
- package/lib/lowcode-components/line-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/line-chart/index.js +5 -2
- package/lib/lowcode-components/line-chart/index.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.d.ts.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.js +3 -0
- package/lib/lowcode-components/lowcode-view/component/abstract-designer-loader.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 +32 -0
- package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/group-layer/controller.d.ts +15 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/controller.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/controller.js +36 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/controller.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/definition.d.ts +10 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/definition.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/definition.js +43 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/definition.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/index.d.ts +11 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/index.d.ts.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/index.js +14 -0
- package/lib/lowcode-components/lowcode-view/component/group-layer/index.js.map +1 -0
- package/lib/lowcode-components/lowcode-view/component/layer-builder.d.ts.map +1 -1
- package/lib/lowcode-components/lowcode-view/component/layer-builder.js +10 -1
- package/lib/lowcode-components/lowcode-view/component/layer-builder.js.map +1 -1
- package/lib/lowcode-components/pie-chart/index.d.ts +1 -0
- package/lib/lowcode-components/pie-chart/index.d.ts.map +1 -1
- package/lib/lowcode-components/pie-chart/index.js +6 -2
- package/lib/lowcode-components/pie-chart/index.js.map +1 -1
- package/lib/lowcode-components/stroke-animation/index.d.ts +27 -0
- package/lib/lowcode-components/stroke-animation/index.d.ts.map +1 -0
- package/lib/lowcode-components/stroke-animation/index.js +144 -0
- package/lib/lowcode-components/stroke-animation/index.js.map +1 -0
- package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-page.js +1 -1
- package/lib/module/dtmpl-edit-page.js.map +1 -1
- package/lib/table/act-table.d.ts +1 -1
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +25 -6
- 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 +17 -6
- package/lib/table/column/column-builder.js.map +1 -1
- package/lib/table/query-table.d.ts.map +1 -1
- package/lib/table/query-table.js +2 -16
- package/lib/table/query-table.js.map +1 -1
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/relation-table.js +11 -6
- package/lib/table/relation-table.js.map +1 -1
- package/lib/table/report-table.d.ts.map +1 -1
- package/lib/table/report-table.js +19 -6
- package/lib/table/report-table.js.map +1 -1
- package/lib/units/index.d.ts +2 -0
- package/lib/units/index.d.ts.map +1 -1
- package/lib/units/index.js +32 -1
- package/lib/units/index.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/action/index.tsx +1 -0
- package/src/aldehyde/controls/action/utils.tsx +2 -3
- package/src/aldehyde/detail/edit/fields-edit-card.tsx +5 -3
- package/src/aldehyde/detail/edit/{row-edit-card.tsx → popover-edit-card.tsx} +1 -1
- package/src/aldehyde/detail/edit/{row-editor.tsx → popover-editor.tsx} +6 -6
- package/src/aldehyde/form/criteria-form.tsx +1 -1
- package/src/aldehyde/form/fields-form.tsx +4 -3
- package/src/aldehyde/layout/menu/user-bar.tsx +2 -1
- package/src/aldehyde/layout2/components/user-button.tsx +2 -1
- package/src/aldehyde/lowcode-components/assets/china.json +1 -1
- package/src/aldehyde/lowcode-components/column-3d-chart/index.tsx +374 -0
- package/src/aldehyde/lowcode-components/effectScatter-map-3d/index.tsx +301 -0
- package/src/aldehyde/lowcode-components/gauge-chart/index.tsx +14 -2
- package/src/aldehyde/lowcode-components/index.ts +11 -2
- package/src/aldehyde/lowcode-components/line-bar-chart/index.tsx +231 -0
- package/src/aldehyde/lowcode-components/line-chart/index.tsx +9 -2
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +4 -1
- package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +32 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +37 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +54 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +16 -0
- package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +9 -1
- package/src/aldehyde/lowcode-components/pie-chart/index.tsx +8 -1
- package/src/aldehyde/lowcode-components/stroke-animation/index.tsx +169 -0
- package/src/aldehyde/module/dtmpl-edit-page.tsx +1 -0
- package/src/aldehyde/table/act-table.tsx +25 -6
- package/src/aldehyde/table/column/column-builder.tsx +17 -11
- package/src/aldehyde/table/query-table.tsx +2 -20
- package/src/aldehyde/table/relation-table.tsx +11 -9
- package/src/aldehyde/table/report-table.tsx +17 -4
- package/src/aldehyde/units/index.tsx +21 -1
- package/lib/detail/edit/row-edit-card.d.ts.map +0 -1
- package/lib/detail/edit/row-edit-card.js.map +0 -1
- package/lib/detail/edit/row-editor.d.ts.map +0 -1
- package/lib/detail/edit/row-editor.js.map +0 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import * as echarts from 'echarts';
|
|
2
|
+
import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import HydrocarbonService from "../../tmpl/hcservice-v3";
|
|
5
|
+
import { DataConfigProps } from "../data";
|
|
6
|
+
|
|
7
|
+
const defData = [["1990", 52], ["1991", 45], ["1992", 35], ["1993", 41], ["1994", 23], ["1995", 25], ["1996", 15]];
|
|
8
|
+
|
|
9
|
+
const defOption = {
|
|
10
|
+
title: {
|
|
11
|
+
text: '暂无数据',
|
|
12
|
+
left: 'center',
|
|
13
|
+
top: 'middle',
|
|
14
|
+
show: false, // 无数据时显示
|
|
15
|
+
},
|
|
16
|
+
color: [],
|
|
17
|
+
tooltip: { trigger: "axis" },
|
|
18
|
+
grid: { top: 30, let: 30, right: 20, bottom: 30 },
|
|
19
|
+
xAxis: {
|
|
20
|
+
type: 'category',
|
|
21
|
+
boundaryGap: true,
|
|
22
|
+
axisTick: { show: true },
|
|
23
|
+
},
|
|
24
|
+
yAxis: {
|
|
25
|
+
type: 'value'
|
|
26
|
+
},
|
|
27
|
+
legend: { show: false },
|
|
28
|
+
series: []
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const legends = {
|
|
32
|
+
top: { top: 0 },
|
|
33
|
+
bottom: { bottom: 0 },
|
|
34
|
+
left: { left: 5, top: "center" },
|
|
35
|
+
right: { right: 5, top: "center" },
|
|
36
|
+
leftTop: { left: 5 },
|
|
37
|
+
rightTop: { right: 5 },
|
|
38
|
+
leftBottom: { left: 5, bottom: 0 },
|
|
39
|
+
rightBottom: { right: 5, bottom: 0 },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// 处理数据格式
|
|
43
|
+
const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
|
|
44
|
+
if (!data?.length) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const temData = data.map((r) => {
|
|
48
|
+
const { config, value } = r;
|
|
49
|
+
const vNames = Object.keys(config).filter((r) => r.startsWith("v")).sort((a, b) => parseInt(a.substring(1)) - parseInt(b.substring(1)));
|
|
50
|
+
return {
|
|
51
|
+
name: config.d1,
|
|
52
|
+
data: vNames.map((r) => ({
|
|
53
|
+
name: config[r],
|
|
54
|
+
data: value.map((v) => [v["d1"], v[r]]),
|
|
55
|
+
}))
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return temData[0]?.data?.[0]?.data || [];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// 绘制左侧面
|
|
62
|
+
const CubeLeft = echarts.graphic.extendShape({
|
|
63
|
+
shape: {
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0
|
|
66
|
+
},
|
|
67
|
+
buildPath: (ctx, shape) => {
|
|
68
|
+
const barWidth = shape.barWidth || 20;
|
|
69
|
+
const offset = barWidth / 2;
|
|
70
|
+
const xAxisPoint = shape.xAxisPoint;
|
|
71
|
+
const c0 = [shape.x, shape.y];
|
|
72
|
+
const c1 = [shape.x - offset, shape.y - offset];
|
|
73
|
+
const c2 = [xAxisPoint[0] - offset, xAxisPoint[1] - offset];
|
|
74
|
+
const c3 = [xAxisPoint[0], xAxisPoint[1]];
|
|
75
|
+
const moveTo: any = ctx.moveTo(c0[0], c0[1]);
|
|
76
|
+
moveTo.lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
// 绘制右侧面
|
|
80
|
+
const CubeRight = echarts.graphic.extendShape({
|
|
81
|
+
shape: {
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0
|
|
84
|
+
},
|
|
85
|
+
buildPath: (ctx, shape) => {
|
|
86
|
+
const barWidth = shape.barWidth || 20;
|
|
87
|
+
const offset2 = barWidth / 10;
|
|
88
|
+
const offset = barWidth / 2 + offset2;
|
|
89
|
+
const xAxisPoint = shape.xAxisPoint;
|
|
90
|
+
const c1 = [shape.x, shape.y];
|
|
91
|
+
const c2 = [xAxisPoint[0], xAxisPoint[1]];
|
|
92
|
+
const c3 = [xAxisPoint[0] + offset, xAxisPoint[1] - offset + 3 * offset2];
|
|
93
|
+
const c4 = [shape.x + offset, shape.y - offset + 3 * offset2];
|
|
94
|
+
const moveTo: any = ctx.moveTo(c1[0], c1[1]);
|
|
95
|
+
moveTo.lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// 绘制顶面
|
|
99
|
+
const CubeTop = echarts.graphic.extendShape({
|
|
100
|
+
shape: {
|
|
101
|
+
x: 0,
|
|
102
|
+
y: 0,
|
|
103
|
+
},
|
|
104
|
+
buildPath: (ctx, shape) => {
|
|
105
|
+
const barWidth = shape.barWidth || 20;
|
|
106
|
+
const offset2 = barWidth / 10;
|
|
107
|
+
const offset = barWidth / 2;
|
|
108
|
+
const c1 = [shape.x, shape.y];
|
|
109
|
+
const c2 = [shape.x + offset + offset2, shape.y - offset + 2 * offset2];
|
|
110
|
+
const c3 = [shape.x + offset2, shape.y - 2 * offset + 2 * offset2];
|
|
111
|
+
const c4 = [shape.x - offset, shape.y - offset];
|
|
112
|
+
const moveTo: any = ctx.moveTo(c1[0], c1[1]);
|
|
113
|
+
moveTo.lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export interface ComponentStyle {
|
|
118
|
+
tooltip?: { show: boolean };
|
|
119
|
+
color?: string;
|
|
120
|
+
grid?: { top: number, let: number, right: number, bottom: number };
|
|
121
|
+
xAxis?: { [key: string]: any };
|
|
122
|
+
yAxis?: { [key: string]: any };
|
|
123
|
+
legend?: { [key: string]: any };
|
|
124
|
+
barWidth?: number; // 柱状图宽度
|
|
125
|
+
isBackground?: boolean; // 是否显示背景
|
|
126
|
+
renderer?: "canvas" | "svg";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ComponentProps {
|
|
130
|
+
style?: ComponentStyle;
|
|
131
|
+
base: { width: number, height: number, type: string },
|
|
132
|
+
data?: DataConfigProps;
|
|
133
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ComponentRef {
|
|
137
|
+
updateConfig: (newConfig: ComponentProps) => void;
|
|
138
|
+
destroy: () => void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
142
|
+
const { style, data: propsData, isDesignMode } = props;
|
|
143
|
+
const [config, setConfig] = useState<ComponentStyle>(style || {});
|
|
144
|
+
const [renderType, setRenderType] = useState<"canvas" | "svg">(style?.renderer || "svg"); // 渲染模式
|
|
145
|
+
const [size, setSize] = useState<{ width: number, height: number }>();
|
|
146
|
+
const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
|
|
147
|
+
const [data, setData] = useState([]);
|
|
148
|
+
const chartRef = useRef<HTMLDivElement>(null);
|
|
149
|
+
const chart = useRef<any>(null);
|
|
150
|
+
const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
|
|
151
|
+
|
|
152
|
+
const handleDestroy = () => {
|
|
153
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
154
|
+
window.removeEventListener('resize', handleResize);
|
|
155
|
+
chart.current && chart.current.dispose();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
useImperativeHandle(ref, () => ({
|
|
159
|
+
updateConfig: (newConfig) => {
|
|
160
|
+
const { base, style: newStyle, data: newDataConfig } = newConfig;
|
|
161
|
+
setConfig({ ...(newStyle || {}) });
|
|
162
|
+
setSize({ width: base.width, height: base.height });
|
|
163
|
+
setDataConfig(newDataConfig);
|
|
164
|
+
setRenderType(newStyle?.renderer || "svg");
|
|
165
|
+
},
|
|
166
|
+
destroy: handleDestroy,
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
// 窗口大小变化时重新调整图表大小
|
|
170
|
+
const handleResize = () => {
|
|
171
|
+
chart.current.resize({ animation: { duration: 500 } });
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
// 注册三个面图形
|
|
176
|
+
echarts.graphic.registerShape('CubeLeft', CubeLeft);
|
|
177
|
+
echarts.graphic.registerShape('CubeRight', CubeRight);
|
|
178
|
+
echarts.graphic.registerShape('CubeTop', CubeTop);
|
|
179
|
+
return () => {
|
|
180
|
+
handleDestroy();
|
|
181
|
+
}
|
|
182
|
+
}, []);
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
handleDestroy();
|
|
186
|
+
chart.current = echarts.init(chartRef.current, null, { renderer: renderType });
|
|
187
|
+
window.addEventListener('resize', handleResize);
|
|
188
|
+
}, [renderType]);
|
|
189
|
+
|
|
190
|
+
// 请求数据
|
|
191
|
+
const getData = async () => {
|
|
192
|
+
const { data } = await HydrocarbonService.requestChartData(null, dataConfig?.sourceId) || {};
|
|
193
|
+
const { config, value } = data || {};
|
|
194
|
+
const temData = handleData(value);
|
|
195
|
+
setData(temData);
|
|
196
|
+
return config;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// 初始化请求数据
|
|
200
|
+
const getInitData = async () => {
|
|
201
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
202
|
+
const config = await getData();
|
|
203
|
+
if (config?.requestMode === "polling") {
|
|
204
|
+
pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// 静态数据处理
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (dataConfig?.sourceType === 'staticData') {
|
|
211
|
+
setData(handleData(dataConfig.staticData));
|
|
212
|
+
}
|
|
213
|
+
}, [dataConfig?.sourceType, dataConfig?.staticData]);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 数据源数据请求
|
|
217
|
+
* 1、编辑态不请求数据
|
|
218
|
+
*/
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
|
|
221
|
+
getInitData();
|
|
222
|
+
} else if (dataConfig?.sourceType === 'sourceId') {
|
|
223
|
+
setData([]);
|
|
224
|
+
}
|
|
225
|
+
}, [dataConfig?.sourceType, dataConfig?.sourceId]);
|
|
226
|
+
|
|
227
|
+
const renderChart = () => {
|
|
228
|
+
const { grid, barWidth, legend, tooltip, color, xAxis, yAxis, isBackground } = config;
|
|
229
|
+
const option = _.cloneDeep(defOption);
|
|
230
|
+
// 编辑态无数据显示默认数据
|
|
231
|
+
const temData = isDesignMode && !data?.length ? defData : data;
|
|
232
|
+
// 背景数据
|
|
233
|
+
let bgData = [];
|
|
234
|
+
if (isBackground) {
|
|
235
|
+
const maxData = Math.max(...temData.map(r => r[1])) + 5;
|
|
236
|
+
bgData = temData.map(r => ([r[0], maxData]));
|
|
237
|
+
}
|
|
238
|
+
option.color = [color]
|
|
239
|
+
option.grid = grid;
|
|
240
|
+
option.legend = { ...legend, ...legends[legend?.position] };
|
|
241
|
+
option.tooltip = { trigger: "axis", ...tooltip };
|
|
242
|
+
option.xAxis = { ...option.xAxis, ...xAxis, axisTick: { show: xAxis?.axisLine?.show } };
|
|
243
|
+
option.yAxis = { ...option.yAxis, ...yAxis };
|
|
244
|
+
option.title.show = !temData?.length;
|
|
245
|
+
option.series = [{
|
|
246
|
+
type: 'custom',
|
|
247
|
+
tooltip: { show: false },
|
|
248
|
+
renderItem: (params, api) => {
|
|
249
|
+
const location = api.coord([api.value(0), api.value(1)]);
|
|
250
|
+
return {
|
|
251
|
+
type: 'group',
|
|
252
|
+
children: [{
|
|
253
|
+
type: 'CubeLeft',
|
|
254
|
+
shape: {
|
|
255
|
+
api,
|
|
256
|
+
x: location[0],
|
|
257
|
+
y: location[1],
|
|
258
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
259
|
+
barWidth,
|
|
260
|
+
},
|
|
261
|
+
style: { fill: `${color}28` }
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
type: 'CubeRight',
|
|
265
|
+
shape: {
|
|
266
|
+
api,
|
|
267
|
+
x: location[0],
|
|
268
|
+
y: location[1],
|
|
269
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
270
|
+
barWidth,
|
|
271
|
+
},
|
|
272
|
+
style: { fill: `${color}32` }
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: 'CubeTop',
|
|
276
|
+
shape: {
|
|
277
|
+
api,
|
|
278
|
+
x: location[0],
|
|
279
|
+
y: location[1],
|
|
280
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
281
|
+
barWidth,
|
|
282
|
+
},
|
|
283
|
+
style: { fill: `${color}50` }
|
|
284
|
+
}]
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
data: bgData
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
type: 'custom',
|
|
291
|
+
renderItem: (params, api) => {
|
|
292
|
+
const location = api.coord([api.value(0), api.value(1)]);
|
|
293
|
+
return {
|
|
294
|
+
type: 'group',
|
|
295
|
+
children: [{
|
|
296
|
+
type: 'CubeLeft',
|
|
297
|
+
shape: {
|
|
298
|
+
api,
|
|
299
|
+
xValue: api.value(0),
|
|
300
|
+
yValue: api.value(1),
|
|
301
|
+
x: location[0],
|
|
302
|
+
y: location[1],
|
|
303
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
304
|
+
barWidth,
|
|
305
|
+
},
|
|
306
|
+
style: {
|
|
307
|
+
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
308
|
+
offset: 0,
|
|
309
|
+
color
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
offset: 0.8,
|
|
313
|
+
color: `${color}5A`
|
|
314
|
+
}
|
|
315
|
+
])
|
|
316
|
+
}
|
|
317
|
+
}, {
|
|
318
|
+
type: 'CubeRight',
|
|
319
|
+
shape: {
|
|
320
|
+
api,
|
|
321
|
+
xValue: api.value(0),
|
|
322
|
+
yValue: api.value(1),
|
|
323
|
+
x: location[0],
|
|
324
|
+
y: location[1],
|
|
325
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
326
|
+
barWidth,
|
|
327
|
+
},
|
|
328
|
+
style: {
|
|
329
|
+
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
330
|
+
offset: 0,
|
|
331
|
+
color: `${color}5A`
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
offset: 0.8,
|
|
335
|
+
color: `${color}50`
|
|
336
|
+
}
|
|
337
|
+
])
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
type: 'CubeTop',
|
|
341
|
+
shape: {
|
|
342
|
+
api,
|
|
343
|
+
xValue: api.value(0),
|
|
344
|
+
yValue: api.value(1),
|
|
345
|
+
x: location[0],
|
|
346
|
+
y: location[1],
|
|
347
|
+
xAxisPoint: api.coord([api.value(0), 0]),
|
|
348
|
+
barWidth,
|
|
349
|
+
},
|
|
350
|
+
style: { fill: color }
|
|
351
|
+
}]
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
data: temData
|
|
355
|
+
}];
|
|
356
|
+
chart.current.setOption(option, true);
|
|
357
|
+
}
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
if (config) {
|
|
360
|
+
renderChart();
|
|
361
|
+
}
|
|
362
|
+
}, [config, data]);
|
|
363
|
+
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
if (size) {
|
|
366
|
+
handleResize();
|
|
367
|
+
}
|
|
368
|
+
}, [size]);
|
|
369
|
+
|
|
370
|
+
return <div ref={chartRef} style={{ width: '100%', height: '100%' }} />;
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
export default Index;
|
|
374
|
+
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import * as echarts from 'echarts';
|
|
2
|
+
import React, { useEffect, useRef, useState, ForwardedRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import chinaJson from "../assets/china.json";
|
|
5
|
+
import HydrocarbonService from "../../tmpl/hcservice-v3";
|
|
6
|
+
import { DataConfigProps } from "../data";
|
|
7
|
+
|
|
8
|
+
const defData = [{ name: '北京', value: [116.41, 40.19, 100] }];
|
|
9
|
+
|
|
10
|
+
const defOption = {
|
|
11
|
+
tooltip: {
|
|
12
|
+
trigger: 'item',
|
|
13
|
+
},
|
|
14
|
+
geo: [
|
|
15
|
+
{ // 边框 map
|
|
16
|
+
zlevel: 6,
|
|
17
|
+
map: "china",
|
|
18
|
+
// 取消一些交互
|
|
19
|
+
select: { disabled: false },
|
|
20
|
+
emphasis: { disabled: true, },
|
|
21
|
+
silent: true,
|
|
22
|
+
// 位置大小调整
|
|
23
|
+
layoutCenter: ["50%", "50%"], //位置
|
|
24
|
+
layoutSize: "125%", //大小
|
|
25
|
+
aspectScale: 0.84,
|
|
26
|
+
// 框颜色
|
|
27
|
+
itemStyle: {
|
|
28
|
+
color: "transparent",
|
|
29
|
+
opacity: 1,
|
|
30
|
+
borderWidth: 1,
|
|
31
|
+
borderColor: "#92C1F0",
|
|
32
|
+
borderCap: "round",
|
|
33
|
+
shadowBlur: 20,
|
|
34
|
+
shadowColor: "#92C1F0",
|
|
35
|
+
borderType: "solid"
|
|
36
|
+
},
|
|
37
|
+
label: {
|
|
38
|
+
show: false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{ // 顶层map
|
|
42
|
+
map: "china",
|
|
43
|
+
zlevel: 5,
|
|
44
|
+
z: 4,
|
|
45
|
+
select: { disabled: false },
|
|
46
|
+
emphasis: { disabled: true, },
|
|
47
|
+
silent: true,
|
|
48
|
+
layoutCenter: ["50%", "50%"], //位置
|
|
49
|
+
layoutSize: "125%", //大小
|
|
50
|
+
aspectScale: 0.84,
|
|
51
|
+
// 调整颜色
|
|
52
|
+
itemStyle: { areaColor: "#02142A" },
|
|
53
|
+
},
|
|
54
|
+
{ // 第二层,下层地图,防3d效果
|
|
55
|
+
zlevel: 5,
|
|
56
|
+
z: 3,
|
|
57
|
+
map: "china",
|
|
58
|
+
select: { disabled: false },
|
|
59
|
+
emphasis: { disabled: true, },
|
|
60
|
+
silent: true,
|
|
61
|
+
layoutCenter: ["50%", "50.6%"], //位置
|
|
62
|
+
layoutSize: "125%", //大小
|
|
63
|
+
aspectScale: 0.84,
|
|
64
|
+
// 颜色
|
|
65
|
+
itemStyle: {
|
|
66
|
+
borderWidth: 0,
|
|
67
|
+
borderCap: "round",
|
|
68
|
+
areaColor: "#38609B",
|
|
69
|
+
},
|
|
70
|
+
regions: [{
|
|
71
|
+
name: '南海诸岛',
|
|
72
|
+
itemStyle: { opacity: 0 },
|
|
73
|
+
label: { show: false }
|
|
74
|
+
}]
|
|
75
|
+
},
|
|
76
|
+
{ // 第三层,下层地图,防3d效果
|
|
77
|
+
zlevel: 5,
|
|
78
|
+
z: 2,
|
|
79
|
+
map: "china",
|
|
80
|
+
select: { disabled: false },
|
|
81
|
+
emphasis: { disabled: true, },
|
|
82
|
+
silent: true,
|
|
83
|
+
layoutCenter: ["50%", "51%"], //位置
|
|
84
|
+
layoutSize: "125%", //大小
|
|
85
|
+
aspectScale: 0.84,
|
|
86
|
+
// 颜色
|
|
87
|
+
itemStyle: {
|
|
88
|
+
borderWidth: 0,
|
|
89
|
+
borderCap: "round",
|
|
90
|
+
areaColor: "#38609B",
|
|
91
|
+
},
|
|
92
|
+
regions: [{
|
|
93
|
+
name: '南海诸岛',
|
|
94
|
+
itemStyle: { opacity: 0 },
|
|
95
|
+
label: { show: false }
|
|
96
|
+
}]
|
|
97
|
+
},
|
|
98
|
+
{ // 第四层,下层地图,防3d效果
|
|
99
|
+
zlevel: 5,
|
|
100
|
+
z: 1,
|
|
101
|
+
map: "china",
|
|
102
|
+
select: { disabled: false },
|
|
103
|
+
emphasis: { disabled: true, },
|
|
104
|
+
silent: true,
|
|
105
|
+
layoutCenter: ["50%", "51.3%"], //位置
|
|
106
|
+
layoutSize: "124.5%", //大小
|
|
107
|
+
aspectScale: 0.84,
|
|
108
|
+
// 颜色
|
|
109
|
+
itemStyle: {
|
|
110
|
+
borderColor: "rgba(0, 0, 0, 0.3)",
|
|
111
|
+
borderWidth: 1,
|
|
112
|
+
borderCap: "round",
|
|
113
|
+
areaColor: "#38609B",
|
|
114
|
+
shadowBlur: 10,
|
|
115
|
+
shadowColor: "rgba(0, 0, 0, 0.6)",
|
|
116
|
+
},
|
|
117
|
+
regions: [{
|
|
118
|
+
name: '南海诸岛',
|
|
119
|
+
itemStyle: { opacity: 0 },
|
|
120
|
+
label: { show: false }
|
|
121
|
+
}]
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
series: [
|
|
125
|
+
{
|
|
126
|
+
type: 'effectScatter',
|
|
127
|
+
coordinateSystem: "geo",
|
|
128
|
+
showEffectOn: 'render',
|
|
129
|
+
rippleEffect: { brushType: 'stroke' },
|
|
130
|
+
label: {
|
|
131
|
+
formatter: '{b}',
|
|
132
|
+
position: 'right',
|
|
133
|
+
show: true,
|
|
134
|
+
},
|
|
135
|
+
itemStyle: {
|
|
136
|
+
color: '#f4e925',
|
|
137
|
+
},
|
|
138
|
+
zlevel: 6,
|
|
139
|
+
encode: { value: 2 },
|
|
140
|
+
data: defData
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// 处理数据格式
|
|
146
|
+
const handleData = (data: { config: { [key: string]: string }, value: { [key: string]: any }[] }[]) => {
|
|
147
|
+
if (!data?.length) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
const temData = data.map((r) => {
|
|
151
|
+
const { config, value } = r;
|
|
152
|
+
const temVal = value.filter(v => v["v2"]);
|
|
153
|
+
return {
|
|
154
|
+
name: config.v1,
|
|
155
|
+
data: temVal.map(v => {
|
|
156
|
+
const lonLat = v["v2"].split(",") || []; // 坐标经纬度;value:[经度,纬度,数值]
|
|
157
|
+
return { name: v["d1"], value: [lonLat[0], lonLat[1], v["v1"]] };
|
|
158
|
+
})
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
return temData[0]?.data || [];
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export interface ComponentStyle {
|
|
165
|
+
tooltip?: { show: boolean };
|
|
166
|
+
effectScatter?: { [key: string]: any };
|
|
167
|
+
areaColor?: string;
|
|
168
|
+
backgroundColor?: string;
|
|
169
|
+
borderColor?: string;
|
|
170
|
+
borderWidth?: number;
|
|
171
|
+
borderType?: string;
|
|
172
|
+
label?: { [key: string]: any };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface ComponentProps {
|
|
176
|
+
style?: ComponentStyle;
|
|
177
|
+
base: { width: number, height: number },
|
|
178
|
+
data?: DataConfigProps;
|
|
179
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface ComponentRef {
|
|
183
|
+
updateConfig: (newConfig: ComponentProps) => void;
|
|
184
|
+
destroy: () => void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>) => {
|
|
188
|
+
const { style, data: propsData, isDesignMode } = props;
|
|
189
|
+
const [config, setConfig] = useState<ComponentStyle>(style || {});
|
|
190
|
+
const [size, setSize] = useState<{ width: number, height: number }>();
|
|
191
|
+
const [dataConfig, setDataConfig] = useState<DataConfigProps>({ ...propsData }); // 数据源配置
|
|
192
|
+
const [data, setData] = useState<{ name: string, value: number[] }[]>([]);
|
|
193
|
+
const chartRef = useRef<HTMLDivElement>(null);
|
|
194
|
+
const chart = useRef<any>(null);
|
|
195
|
+
const pollingIntervalRef = useRef<number | NodeJS.Timeout>(null);
|
|
196
|
+
|
|
197
|
+
const handleDestroy = () => {
|
|
198
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
199
|
+
window.removeEventListener('resize', handleResize);
|
|
200
|
+
chart.current.dispose();
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
useImperativeHandle(ref, () => ({
|
|
204
|
+
updateConfig: (newConfig) => {
|
|
205
|
+
const { base, style: newStyle, data: newDataConfig } = newConfig;
|
|
206
|
+
setConfig({ ...(newStyle || {}) });
|
|
207
|
+
setSize({ width: base.width, height: base.height });
|
|
208
|
+
setDataConfig(newDataConfig);
|
|
209
|
+
},
|
|
210
|
+
destroy: handleDestroy,
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
// 窗口大小变化时重新调整图表大小
|
|
214
|
+
const handleResize = () => {
|
|
215
|
+
chart.current.resize({ animation: { duration: 500 } });
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
echarts.registerMap('china', chinaJson as any);
|
|
220
|
+
chart.current = echarts.init(chartRef.current, null, { renderer: "svg" });
|
|
221
|
+
window.addEventListener('resize', handleResize);
|
|
222
|
+
return () => {
|
|
223
|
+
handleDestroy();
|
|
224
|
+
}
|
|
225
|
+
}, []);
|
|
226
|
+
|
|
227
|
+
// 请求数据
|
|
228
|
+
const getData = async () => {
|
|
229
|
+
const { data } = await HydrocarbonService.requestChartData(null, dataConfig?.sourceId) || {};
|
|
230
|
+
const { config, value } = data || {};
|
|
231
|
+
setData(handleData(value));
|
|
232
|
+
return config;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// 初始化请求数据
|
|
236
|
+
const getInitData = async () => {
|
|
237
|
+
pollingIntervalRef.current && clearInterval(pollingIntervalRef.current);
|
|
238
|
+
const config = await getData();
|
|
239
|
+
if (config?.requestMode === "polling") {
|
|
240
|
+
pollingIntervalRef.current = setInterval(() => { getData() }, config?.pollingInterval || 60000);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// 静态数据处理
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
if (dataConfig?.sourceType === 'staticData') {
|
|
247
|
+
setData(dataConfig.staticData || []);
|
|
248
|
+
}
|
|
249
|
+
}, [dataConfig?.sourceType, dataConfig?.staticData]);
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* 数据源数据请求
|
|
253
|
+
* 1、编辑态不请求数据
|
|
254
|
+
*/
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
if (!isDesignMode && dataConfig?.sourceType === 'sourceId' && dataConfig?.sourceId) {
|
|
257
|
+
getInitData();
|
|
258
|
+
} else if (dataConfig?.sourceType === 'sourceId') {
|
|
259
|
+
setData([]);
|
|
260
|
+
}
|
|
261
|
+
}, [dataConfig?.sourceType, dataConfig?.sourceId]);
|
|
262
|
+
|
|
263
|
+
const renderChart = () => {
|
|
264
|
+
const { tooltip, areaColor, backgroundColor, borderColor, borderWidth, borderType, label, effectScatter } = config
|
|
265
|
+
const option = _.cloneDeep(defOption);
|
|
266
|
+
// 编辑态无数据显示默认数据
|
|
267
|
+
const temData = isDesignMode && !data?.length ? defData : data;
|
|
268
|
+
option.tooltip = { trigger: "item", ...tooltip };
|
|
269
|
+
option.geo = option.geo.map((r, index) => {
|
|
270
|
+
switch (index) {
|
|
271
|
+
case 0:
|
|
272
|
+
return { ...r, label, itemStyle: { ...r.itemStyle, borderWidth, borderColor, shadowColor: borderColor, borderType } };
|
|
273
|
+
case 1:
|
|
274
|
+
return { ...r, itemStyle: { areaColor } };
|
|
275
|
+
case 2:
|
|
276
|
+
case 3:
|
|
277
|
+
case 4:
|
|
278
|
+
return { ...r, itemStyle: { ...r.itemStyle, areaColor: backgroundColor } };
|
|
279
|
+
default:
|
|
280
|
+
return r;
|
|
281
|
+
}
|
|
282
|
+
}) as any;
|
|
283
|
+
option.series = option.series.map((item: any) => ({ ...item, ...effectScatter, data: temData }));
|
|
284
|
+
chart.current.setOption(option, true);
|
|
285
|
+
}
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (config) {
|
|
288
|
+
renderChart();
|
|
289
|
+
}
|
|
290
|
+
}, [config, data]);
|
|
291
|
+
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (size) {
|
|
294
|
+
handleResize();
|
|
295
|
+
}
|
|
296
|
+
}, [size]);
|
|
297
|
+
|
|
298
|
+
return <div ref={chartRef} style={{ width: '100%', height: '100%' }} />;
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
export default Index;
|
|
@@ -140,11 +140,23 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
|
|
|
140
140
|
option.tooltip = { trigger: "item", ...tooltip };
|
|
141
141
|
// 编辑态数据源类型显示默认数据50
|
|
142
142
|
const temData = isDesignMode && dataConfig?.sourceType === 'sourceId' ? 50 : (data || 0);
|
|
143
|
+
// 进度条配置
|
|
144
|
+
const color1 = progress?.itemStyle?.color[0];
|
|
145
|
+
const color2 = progress?.itemStyle?.color[1];
|
|
146
|
+
const progressConfig = progress ? {
|
|
147
|
+
...progress, itemStyle: {
|
|
148
|
+
...progress?.itemStyle,
|
|
149
|
+
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
150
|
+
{ offset: 0, color: color2 || color1 },
|
|
151
|
+
{ offset: 1, color: color1 }
|
|
152
|
+
])
|
|
153
|
+
}
|
|
154
|
+
} : undefined
|
|
143
155
|
option.series = option.series.map((r) => ({
|
|
144
156
|
...r,
|
|
145
157
|
pointer: {
|
|
146
158
|
itemStyle: {
|
|
147
|
-
color: progress?.show ?
|
|
159
|
+
color: progress?.show ? color1 : 'auto'
|
|
148
160
|
}
|
|
149
161
|
},
|
|
150
162
|
radius: `${radius}%`,
|
|
@@ -153,7 +165,7 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
|
|
|
153
165
|
endAngle,
|
|
154
166
|
min,
|
|
155
167
|
max,
|
|
156
|
-
progress,
|
|
168
|
+
progress: progressConfig,
|
|
157
169
|
axisLine: temAxisLine,
|
|
158
170
|
splitLine,
|
|
159
171
|
axisTick,
|