@publishfx/publish-chart 1.3.2 → 1.4.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.
- package/dist/components/composite/GroupBar.d.ts +4 -0
- package/dist/components/composite/GroupBar.js +425 -0
- package/dist/components/composite/GroupLine.d.ts +2 -0
- package/dist/components/composite/GroupLine.js +310 -0
- package/dist/components/composite/GroupLineCompare.d.ts +3 -0
- package/dist/components/composite/GroupLineCompare.js +496 -0
- package/dist/components/composite/MultipleCompareLine.d.ts +2 -0
- package/dist/components/composite/MultipleCompareLine.js +356 -0
- package/dist/components/composite/MultipleLine.d.ts +2 -0
- package/dist/components/composite/MultipleLine.js +313 -0
- package/dist/components/shared/NodeGeom.js +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -1
- package/package.json +2 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Axis, Chart, Legend, Line, Tooltip, View } from "bizcharts";
|
|
4
|
+
import lib from "@antv/data-set/lib";
|
|
5
|
+
import { calculateBarWidth, getAxisFormat, getAxisHorPaddingByText } from "../../utils/chartHelpers.js";
|
|
6
|
+
import { defaultChartConfig, nodeMap } from "../../core/ChartConfig.js";
|
|
7
|
+
import { formatIndicatorV2 } from "../../utils/formatters.js";
|
|
8
|
+
import { getIndicatorName } from "../../utils/indicatorHelpers.js";
|
|
9
|
+
import AuxiliaryLine from "../shared/AuxiliaryLine.js";
|
|
10
|
+
import XAxisBackground from "../shared/XAxisBackground.js";
|
|
11
|
+
import { NodeGeom } from "../shared/NodeGeom.js";
|
|
12
|
+
const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupType', indicatorMap, config, auxiliaryLineData, nodeSetting = {
|
|
13
|
+
showType: 0,
|
|
14
|
+
type: []
|
|
15
|
+
}, highlightDate, timeRange })=>{
|
|
16
|
+
const yAxis = 'groupValue';
|
|
17
|
+
const { isDataTag = true, isLegend = true, isHighlight = true } = config || {};
|
|
18
|
+
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
19
|
+
const [padding, setPadding] = useState([
|
|
20
|
+
20,
|
|
21
|
+
10,
|
|
22
|
+
10,
|
|
23
|
+
0
|
|
24
|
+
]);
|
|
25
|
+
const [mainBarSize, setMainBarSize] = useState(void 0);
|
|
26
|
+
const ds = new lib();
|
|
27
|
+
const dv = ds.createView().source(data);
|
|
28
|
+
dv.transform({
|
|
29
|
+
type: 'map',
|
|
30
|
+
callback (row) {
|
|
31
|
+
row[yAxis] = '' !== row[yAxis] ? +row[yAxis] : '-';
|
|
32
|
+
return row;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const transformData = dv.rows;
|
|
36
|
+
let maxY = Math.max(...dv.rows.filter((item)=>'-' !== item[yAxis]).map((item)=>item[yAxis]));
|
|
37
|
+
if (auxiliaryLineData?.length) {
|
|
38
|
+
const maxAuxiliaryLine = Math.max(...auxiliaryLineData.map((item)=>+item.value));
|
|
39
|
+
if (maxAuxiliaryLine > maxY) maxY = maxAuxiliaryLine;
|
|
40
|
+
}
|
|
41
|
+
transformData.forEach((item)=>{
|
|
42
|
+
const infos = [
|
|
43
|
+
...item?.nodeInfos?.info || [],
|
|
44
|
+
...item?.nodeInfos?.infosCompare || []
|
|
45
|
+
];
|
|
46
|
+
const len = infos.length || 0;
|
|
47
|
+
item.nodeLen = len;
|
|
48
|
+
if (0 === len) return;
|
|
49
|
+
item.node = 0;
|
|
50
|
+
item.color = 1 == len ? nodeMap.get(infos[0].type)?.color : 'l (0) 0:#32C5FF 0.44:#B620E0 0.99:#F7B500';
|
|
51
|
+
});
|
|
52
|
+
const [pointP, setPointP] = useState({
|
|
53
|
+
x: 0,
|
|
54
|
+
y: 0
|
|
55
|
+
});
|
|
56
|
+
const [pointData, setPointData] = useState({
|
|
57
|
+
info: [],
|
|
58
|
+
infosCompare: []
|
|
59
|
+
});
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
setPointP({
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0
|
|
64
|
+
});
|
|
65
|
+
setPointData({
|
|
66
|
+
info: [],
|
|
67
|
+
infosCompare: []
|
|
68
|
+
});
|
|
69
|
+
}, [
|
|
70
|
+
data
|
|
71
|
+
]);
|
|
72
|
+
useEffect(()=>{
|
|
73
|
+
if (maxY > Math.max(...dv.rows.filter((item)=>'-' !== item[yAxis]).map((item)=>item[yAxis]))) setPadding((pre)=>[
|
|
74
|
+
25,
|
|
75
|
+
pre[1],
|
|
76
|
+
pre[2],
|
|
77
|
+
pre[3]
|
|
78
|
+
]);
|
|
79
|
+
}, [
|
|
80
|
+
maxY,
|
|
81
|
+
data
|
|
82
|
+
]);
|
|
83
|
+
const filterFn = useMemo(()=>(item)=>highlightDate?.includes(item.groupName) ?? false, [
|
|
84
|
+
highlightDate
|
|
85
|
+
]);
|
|
86
|
+
const nodeViewData = useMemo(()=>{
|
|
87
|
+
const uniqueMap = new Map();
|
|
88
|
+
transformData.forEach((item)=>{
|
|
89
|
+
const hasNode = (item?.nodeInfos?.info?.length || 0) > 0 || (item?.nodeInfos?.infosCompare?.length || 0) > 0;
|
|
90
|
+
if (hasNode && !uniqueMap.has(item.groupName)) uniqueMap.set(item.groupName, {
|
|
91
|
+
groupName: item.groupName,
|
|
92
|
+
node: 0,
|
|
93
|
+
nodeInfos: item.nodeInfos,
|
|
94
|
+
color: item.color,
|
|
95
|
+
[legend]: 'NodeEvent'
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return Array.from(uniqueMap.values());
|
|
99
|
+
}, [
|
|
100
|
+
transformData
|
|
101
|
+
]);
|
|
102
|
+
return /*#__PURE__*/ jsxs(Chart, {
|
|
103
|
+
height: height || 300,
|
|
104
|
+
data: transformData,
|
|
105
|
+
scale: {
|
|
106
|
+
[yAxis]: {
|
|
107
|
+
type: 'linear',
|
|
108
|
+
max: maxY,
|
|
109
|
+
nice: true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
...defaultChartConfig.baseChartConfig,
|
|
113
|
+
appendPadding: padding,
|
|
114
|
+
onPointMouseover: (e)=>{
|
|
115
|
+
if (1 == nodeSetting.showType) {
|
|
116
|
+
setPointP({
|
|
117
|
+
x: e.data.x,
|
|
118
|
+
y: e.data.y
|
|
119
|
+
});
|
|
120
|
+
setPointData(e.data.data.nodeInfos);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
onAfterrender: (_e, chart)=>{
|
|
124
|
+
const estimatedBarWidth = calculateBarWidth(chart, transformData, x, 0.5);
|
|
125
|
+
if (void 0 !== estimatedBarWidth) setMainBarSize(estimatedBarWidth);
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ jsx(XAxisBackground, {
|
|
129
|
+
x: x,
|
|
130
|
+
data: transformData,
|
|
131
|
+
isHighlight: isHighlight,
|
|
132
|
+
filterFn: filterFn,
|
|
133
|
+
dataLength: transformData.length,
|
|
134
|
+
mainBarSize: mainBarSize
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ jsx(Line, {
|
|
137
|
+
position: `${x}*${yAxis}`,
|
|
138
|
+
style: [
|
|
139
|
+
legend,
|
|
140
|
+
(groupType)=>{
|
|
141
|
+
if (groupType.includes('_compare')) return {
|
|
142
|
+
lineDash: [
|
|
143
|
+
4,
|
|
144
|
+
4
|
|
145
|
+
]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
state: {
|
|
150
|
+
active: {
|
|
151
|
+
style: (element)=>{
|
|
152
|
+
if ('dash' === element.getModel().shape) return {
|
|
153
|
+
lineDash: [
|
|
154
|
+
4,
|
|
155
|
+
4
|
|
156
|
+
],
|
|
157
|
+
lineWidth: 3
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
lineWidth: 3
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
color: legend,
|
|
166
|
+
shape: [
|
|
167
|
+
legend,
|
|
168
|
+
(groupType)=>{
|
|
169
|
+
if (groupType.includes('_compare')) return 'dash';
|
|
170
|
+
return 'line';
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
label: [
|
|
174
|
+
`${legend}*${yAxis}`,
|
|
175
|
+
(name, value)=>{
|
|
176
|
+
let indicator = name;
|
|
177
|
+
if (indicator.includes('_compare')) indicator = indicator.split('_')[0];
|
|
178
|
+
return {
|
|
179
|
+
content: isDataTag ? formatIndicatorV2(value, indicatorMap[indicator]) : ''
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
185
|
+
shared: true,
|
|
186
|
+
showCrosshairs: true,
|
|
187
|
+
children: (title, items)=>{
|
|
188
|
+
let AuxiindicatorName = '';
|
|
189
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
190
|
+
style: {
|
|
191
|
+
padding: '10px 0'
|
|
192
|
+
},
|
|
193
|
+
children: [
|
|
194
|
+
title,
|
|
195
|
+
items && /*#__PURE__*/ jsxs(Fragment, {
|
|
196
|
+
children: [
|
|
197
|
+
/*#__PURE__*/ jsx("div", {
|
|
198
|
+
children: items.map((it, index)=>{
|
|
199
|
+
if (0 === index) AuxiindicatorName = it.name.split('_')[0];
|
|
200
|
+
let indicator = it.name;
|
|
201
|
+
if (indicator.includes('_compare')) indicator = indicator.split('_')[0];
|
|
202
|
+
const indicatorName = getIndicatorName(indicatorMap, indicator);
|
|
203
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
204
|
+
style: {
|
|
205
|
+
display: 'flex',
|
|
206
|
+
justifyContent: 'space-between',
|
|
207
|
+
marginTop: '10px'
|
|
208
|
+
},
|
|
209
|
+
children: [
|
|
210
|
+
/*#__PURE__*/ jsxs("span", {
|
|
211
|
+
children: [
|
|
212
|
+
/*#__PURE__*/ jsx("span", {
|
|
213
|
+
style: {
|
|
214
|
+
width: '8px',
|
|
215
|
+
height: '8px',
|
|
216
|
+
backgroundColor: it.color,
|
|
217
|
+
display: 'inline-block',
|
|
218
|
+
borderRadius: '50%',
|
|
219
|
+
marginRight: '8px'
|
|
220
|
+
}
|
|
221
|
+
}),
|
|
222
|
+
it.name.includes('_compare') ? `${indicatorName}(${it.data.compareTime})` : indicatorName,
|
|
223
|
+
":"
|
|
224
|
+
]
|
|
225
|
+
}),
|
|
226
|
+
/*#__PURE__*/ jsx("span", {
|
|
227
|
+
style: {
|
|
228
|
+
fontWeight: 'bold',
|
|
229
|
+
paddingLeft: '10px'
|
|
230
|
+
},
|
|
231
|
+
children: formatIndicatorV2(it.value, indicatorMap[indicator])
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
}, index);
|
|
235
|
+
})
|
|
236
|
+
}),
|
|
237
|
+
auxiliaryLineData && auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsxs("div", {
|
|
238
|
+
style: {
|
|
239
|
+
marginLeft: '16px',
|
|
240
|
+
marginTop: '10px',
|
|
241
|
+
display: 'flex',
|
|
242
|
+
justifyContent: 'space-between'
|
|
243
|
+
},
|
|
244
|
+
children: [
|
|
245
|
+
/*#__PURE__*/ jsxs("div", {
|
|
246
|
+
children: [
|
|
247
|
+
item.name,
|
|
248
|
+
":"
|
|
249
|
+
]
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ jsx("div", {
|
|
252
|
+
children: formatIndicatorV2(item.value, indicatorMap[AuxiindicatorName])
|
|
253
|
+
})
|
|
254
|
+
]
|
|
255
|
+
}, index))
|
|
256
|
+
]
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
auxiliaryLineData?.length > 0 && /*#__PURE__*/ jsxs(View, {
|
|
263
|
+
data: transformData,
|
|
264
|
+
scale: {
|
|
265
|
+
[yAxis]: {
|
|
266
|
+
type: 'linear',
|
|
267
|
+
max: maxY,
|
|
268
|
+
nice: true
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
padding: [
|
|
272
|
+
0,
|
|
273
|
+
0,
|
|
274
|
+
0,
|
|
275
|
+
-axisHorPadding
|
|
276
|
+
],
|
|
277
|
+
children: [
|
|
278
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
279
|
+
name: yAxis,
|
|
280
|
+
visible: false
|
|
281
|
+
}),
|
|
282
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
283
|
+
name: x,
|
|
284
|
+
visible: false
|
|
285
|
+
}),
|
|
286
|
+
/*#__PURE__*/ jsx(Line, {
|
|
287
|
+
position: `${x}*${yAxis}`,
|
|
288
|
+
visible: false
|
|
289
|
+
}),
|
|
290
|
+
auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsx(AuxiliaryLine, {
|
|
291
|
+
name: item.name,
|
|
292
|
+
value: item.value
|
|
293
|
+
}, index))
|
|
294
|
+
]
|
|
295
|
+
}, axisHorPadding),
|
|
296
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
297
|
+
name: legend,
|
|
298
|
+
position: "bottom-left",
|
|
299
|
+
visible: isLegend,
|
|
300
|
+
maxItemWidth: 1,
|
|
301
|
+
flipPage: false,
|
|
302
|
+
maxHeightRatio: 0.4,
|
|
303
|
+
itemName: {
|
|
304
|
+
formatter (text) {
|
|
305
|
+
let indicator = text;
|
|
306
|
+
if (indicator.includes('_compare')) indicator = indicator.split('_')[0];
|
|
307
|
+
const indicatorName = getIndicatorName(indicatorMap, indicator);
|
|
308
|
+
return text.includes('_compare') ? `${indicatorName}(对比时间:${timeRange?.compareStartTime}~${timeRange?.compareEndTime})` : indicatorName;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}),
|
|
312
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
313
|
+
name: "color",
|
|
314
|
+
visible: false
|
|
315
|
+
}),
|
|
316
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
317
|
+
name: yAxis,
|
|
318
|
+
label: {
|
|
319
|
+
formatter (val) {
|
|
320
|
+
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, '') - 22);
|
|
321
|
+
return getAxisFormat(val, indicatorMap, '');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}),
|
|
325
|
+
nodeViewData.length > 0 && 1 == nodeSetting.showType && /*#__PURE__*/ jsxs(View, {
|
|
326
|
+
data: nodeViewData,
|
|
327
|
+
scale: {
|
|
328
|
+
node: {
|
|
329
|
+
min: 0,
|
|
330
|
+
max: 1
|
|
331
|
+
},
|
|
332
|
+
groupName: {
|
|
333
|
+
type: 'cat'
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
children: [
|
|
337
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
338
|
+
name: "node",
|
|
339
|
+
visible: false
|
|
340
|
+
}),
|
|
341
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
342
|
+
name: "color",
|
|
343
|
+
visible: false
|
|
344
|
+
}),
|
|
345
|
+
/*#__PURE__*/ jsx(NodeGeom, {
|
|
346
|
+
pointData: pointData,
|
|
347
|
+
pointP: pointP,
|
|
348
|
+
isLegend: isLegend
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
]
|
|
353
|
+
}, nodeSetting?.showType + JSON.stringify(config));
|
|
354
|
+
};
|
|
355
|
+
const composite_MultipleCompareLine = /*#__PURE__*/ memo(MultipleCompareLine);
|
|
356
|
+
export { composite_MultipleCompareLine as default };
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Axis, Chart, Legend, Line, Tooltip, View } from "bizcharts";
|
|
4
|
+
import lib from "@antv/data-set/lib";
|
|
5
|
+
import { calculateBarWidth, getAxisFormat, getAxisHorPaddingByText } from "../../utils/chartHelpers.js";
|
|
6
|
+
import { defaultChartConfig, nodeMap } from "../../core/ChartConfig.js";
|
|
7
|
+
import { formatIndicatorV2 } from "../../utils/formatters.js";
|
|
8
|
+
import { getIndicatorName } from "../../utils/indicatorHelpers.js";
|
|
9
|
+
import AuxiliaryLine from "../shared/AuxiliaryLine.js";
|
|
10
|
+
import XAxisBackground from "../shared/XAxisBackground.js";
|
|
11
|
+
import { NodeGeom } from "../shared/NodeGeom.js";
|
|
12
|
+
const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', indicatorMap, config, auxiliaryLineData, nodeSetting = {
|
|
13
|
+
showType: 0,
|
|
14
|
+
type: []
|
|
15
|
+
}, highlightDate })=>{
|
|
16
|
+
const yAxis = 'groupValue';
|
|
17
|
+
const { isDataTag = true, isLegend = true, isHighlight = true } = config || {};
|
|
18
|
+
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
19
|
+
const [padding, setPadding] = useState([
|
|
20
|
+
20,
|
|
21
|
+
10,
|
|
22
|
+
10,
|
|
23
|
+
0
|
|
24
|
+
]);
|
|
25
|
+
const [mainBarSize, setMainBarSize] = useState(void 0);
|
|
26
|
+
const ds = new lib();
|
|
27
|
+
const dv = ds.createView().source(data);
|
|
28
|
+
dv.transform({
|
|
29
|
+
type: 'map',
|
|
30
|
+
callback (row) {
|
|
31
|
+
row[yAxis] = '' !== row[yAxis] ? +row[yAxis] : '-';
|
|
32
|
+
return row;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const transformData = dv.rows;
|
|
36
|
+
let maxY = Math.max(...dv.rows.filter((item)=>'-' !== item[yAxis]).map((item)=>item[yAxis]));
|
|
37
|
+
if (auxiliaryLineData?.length) {
|
|
38
|
+
const maxAuxiliaryLine = Math.max(...auxiliaryLineData.map((item)=>+item.value));
|
|
39
|
+
if (maxAuxiliaryLine > maxY) maxY = maxAuxiliaryLine;
|
|
40
|
+
}
|
|
41
|
+
transformData.forEach((item)=>{
|
|
42
|
+
const infos = [
|
|
43
|
+
...item?.nodeInfos?.info || [],
|
|
44
|
+
...item?.nodeInfos?.infosCompare || []
|
|
45
|
+
];
|
|
46
|
+
const len = infos.length || 0;
|
|
47
|
+
item.nodeLen = len;
|
|
48
|
+
if (0 === len) return;
|
|
49
|
+
item.node = 0;
|
|
50
|
+
item.color = 1 == len ? nodeMap.get(infos[0].type)?.color : 'l (0) 0:#32C5FF 0.44:#B620E0 0.99:#F7B500';
|
|
51
|
+
});
|
|
52
|
+
const [pointP, setPointP] = useState({
|
|
53
|
+
x: 0,
|
|
54
|
+
y: 0
|
|
55
|
+
});
|
|
56
|
+
const [pointData, setPointData] = useState({
|
|
57
|
+
info: [],
|
|
58
|
+
infosCompare: []
|
|
59
|
+
});
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
setPointP({
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0
|
|
64
|
+
});
|
|
65
|
+
setPointData({
|
|
66
|
+
info: [],
|
|
67
|
+
infosCompare: []
|
|
68
|
+
});
|
|
69
|
+
}, [
|
|
70
|
+
data
|
|
71
|
+
]);
|
|
72
|
+
useEffect(()=>{
|
|
73
|
+
if (maxY > Math.max(...dv.rows.filter((item)=>'-' !== item[yAxis]).map((item)=>item[yAxis]))) setPadding((pre)=>[
|
|
74
|
+
25,
|
|
75
|
+
pre[1],
|
|
76
|
+
pre[2],
|
|
77
|
+
pre[3]
|
|
78
|
+
]);
|
|
79
|
+
}, [
|
|
80
|
+
maxY,
|
|
81
|
+
data
|
|
82
|
+
]);
|
|
83
|
+
const filterFn = useMemo(()=>(item)=>highlightDate?.includes(item.groupName) ?? false, [
|
|
84
|
+
highlightDate
|
|
85
|
+
]);
|
|
86
|
+
const nodeViewData = useMemo(()=>{
|
|
87
|
+
const uniqueMap = new Map();
|
|
88
|
+
transformData.forEach((item)=>{
|
|
89
|
+
const hasNode = (item?.nodeInfos?.info?.length || 0) > 0 || (item?.nodeInfos?.infosCompare?.length || 0) > 0;
|
|
90
|
+
if (hasNode && !uniqueMap.has(item.groupName)) uniqueMap.set(item.groupName, {
|
|
91
|
+
groupName: item.groupName,
|
|
92
|
+
node: 0,
|
|
93
|
+
nodeInfos: item.nodeInfos,
|
|
94
|
+
color: item.color,
|
|
95
|
+
[legend]: 'NodeEvent'
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return Array.from(uniqueMap.values());
|
|
99
|
+
}, [
|
|
100
|
+
transformData
|
|
101
|
+
]);
|
|
102
|
+
return /*#__PURE__*/ jsxs(Chart, {
|
|
103
|
+
height: height || 300,
|
|
104
|
+
data: transformData,
|
|
105
|
+
scale: {
|
|
106
|
+
[yAxis]: {
|
|
107
|
+
type: 'linear',
|
|
108
|
+
max: maxY,
|
|
109
|
+
nice: true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
...defaultChartConfig.baseChartConfig,
|
|
113
|
+
appendPadding: padding,
|
|
114
|
+
onPointMouseover: (e)=>{
|
|
115
|
+
if (1 == nodeSetting.showType) {
|
|
116
|
+
setPointP({
|
|
117
|
+
x: e.data.x,
|
|
118
|
+
y: e.data.y
|
|
119
|
+
});
|
|
120
|
+
setPointData(e.data.data.nodeInfos);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
onAfterrender: (_e, chart)=>{
|
|
124
|
+
const estimatedBarWidth = calculateBarWidth(chart, transformData, x, 0.5);
|
|
125
|
+
if (void 0 !== estimatedBarWidth) setMainBarSize(estimatedBarWidth);
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ jsx(XAxisBackground, {
|
|
129
|
+
x: x,
|
|
130
|
+
data: transformData,
|
|
131
|
+
isHighlight: isHighlight,
|
|
132
|
+
filterFn: filterFn,
|
|
133
|
+
dataLength: transformData.length,
|
|
134
|
+
mainBarSize: mainBarSize
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ jsx(Line, {
|
|
137
|
+
position: `${x}*${yAxis}`,
|
|
138
|
+
style: {
|
|
139
|
+
cursor: 'pointer'
|
|
140
|
+
},
|
|
141
|
+
color: legend,
|
|
142
|
+
label: [
|
|
143
|
+
`${legend}*${yAxis}`,
|
|
144
|
+
(name, value)=>({
|
|
145
|
+
content: isDataTag ? formatIndicatorV2(value, indicatorMap[name]) : ''
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}),
|
|
149
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
150
|
+
shared: true,
|
|
151
|
+
showCrosshairs: true,
|
|
152
|
+
children: (title, items)=>{
|
|
153
|
+
let indicatorName = '';
|
|
154
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
155
|
+
style: {
|
|
156
|
+
padding: '10px 0'
|
|
157
|
+
},
|
|
158
|
+
children: [
|
|
159
|
+
title,
|
|
160
|
+
items && /*#__PURE__*/ jsxs(Fragment, {
|
|
161
|
+
children: [
|
|
162
|
+
/*#__PURE__*/ jsx("div", {
|
|
163
|
+
children: items.map((it, index)=>{
|
|
164
|
+
if (0 === index) indicatorName = it.name;
|
|
165
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
166
|
+
style: {
|
|
167
|
+
display: 'flex',
|
|
168
|
+
justifyContent: 'space-between',
|
|
169
|
+
marginTop: '10px'
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ jsxs("span", {
|
|
173
|
+
children: [
|
|
174
|
+
/*#__PURE__*/ jsx("span", {
|
|
175
|
+
style: {
|
|
176
|
+
width: '8px',
|
|
177
|
+
height: '8px',
|
|
178
|
+
backgroundColor: it.color,
|
|
179
|
+
display: 'inline-block',
|
|
180
|
+
borderRadius: '50%',
|
|
181
|
+
marginRight: '8px'
|
|
182
|
+
}
|
|
183
|
+
}),
|
|
184
|
+
getIndicatorName(indicatorMap, it.name),
|
|
185
|
+
":"
|
|
186
|
+
]
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ jsx("span", {
|
|
189
|
+
style: {
|
|
190
|
+
fontWeight: 'bold',
|
|
191
|
+
paddingLeft: '10px'
|
|
192
|
+
},
|
|
193
|
+
children: formatIndicatorV2(it.value, indicatorMap[it.name])
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
}, index);
|
|
197
|
+
})
|
|
198
|
+
}),
|
|
199
|
+
auxiliaryLineData && auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsxs("div", {
|
|
200
|
+
style: {
|
|
201
|
+
marginLeft: '16px',
|
|
202
|
+
marginTop: '10px',
|
|
203
|
+
display: 'flex',
|
|
204
|
+
justifyContent: 'space-between'
|
|
205
|
+
},
|
|
206
|
+
children: [
|
|
207
|
+
/*#__PURE__*/ jsxs("div", {
|
|
208
|
+
children: [
|
|
209
|
+
item.name,
|
|
210
|
+
":"
|
|
211
|
+
]
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ jsx("div", {
|
|
214
|
+
children: formatIndicatorV2(item.value, indicatorMap[indicatorName])
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
}, index))
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
auxiliaryLineData?.length > 0 && /*#__PURE__*/ jsxs(View, {
|
|
225
|
+
data: transformData,
|
|
226
|
+
scale: {
|
|
227
|
+
[yAxis]: {
|
|
228
|
+
type: 'linear',
|
|
229
|
+
max: maxY,
|
|
230
|
+
nice: true
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
padding: [
|
|
234
|
+
0,
|
|
235
|
+
0,
|
|
236
|
+
0,
|
|
237
|
+
-axisHorPadding
|
|
238
|
+
],
|
|
239
|
+
children: [
|
|
240
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
241
|
+
name: yAxis,
|
|
242
|
+
visible: false
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
245
|
+
name: x,
|
|
246
|
+
visible: false
|
|
247
|
+
}),
|
|
248
|
+
/*#__PURE__*/ jsx(Line, {
|
|
249
|
+
position: `${x}*${yAxis}`,
|
|
250
|
+
visible: false
|
|
251
|
+
}),
|
|
252
|
+
auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsx(AuxiliaryLine, {
|
|
253
|
+
name: item.name,
|
|
254
|
+
value: item.value
|
|
255
|
+
}, index))
|
|
256
|
+
]
|
|
257
|
+
}, axisHorPadding),
|
|
258
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
259
|
+
name: legend,
|
|
260
|
+
position: "bottom-left",
|
|
261
|
+
maxItemWidth: 1,
|
|
262
|
+
visible: isLegend,
|
|
263
|
+
itemName: {
|
|
264
|
+
formatter (text) {
|
|
265
|
+
return getIndicatorName(indicatorMap, text);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}),
|
|
269
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
270
|
+
name: "color",
|
|
271
|
+
visible: false
|
|
272
|
+
}),
|
|
273
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
274
|
+
name: yAxis,
|
|
275
|
+
label: {
|
|
276
|
+
formatter (val) {
|
|
277
|
+
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, '') - 22);
|
|
278
|
+
return getAxisFormat(val, indicatorMap, '');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
282
|
+
nodeViewData.length > 0 && 1 == nodeSetting.showType && /*#__PURE__*/ jsxs(View, {
|
|
283
|
+
data: nodeViewData,
|
|
284
|
+
scale: {
|
|
285
|
+
node: {
|
|
286
|
+
min: 0,
|
|
287
|
+
max: 1
|
|
288
|
+
},
|
|
289
|
+
groupName: {
|
|
290
|
+
type: 'cat'
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
children: [
|
|
294
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
295
|
+
name: "node",
|
|
296
|
+
visible: false
|
|
297
|
+
}),
|
|
298
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
299
|
+
name: "color",
|
|
300
|
+
visible: false
|
|
301
|
+
}),
|
|
302
|
+
/*#__PURE__*/ jsx(NodeGeom, {
|
|
303
|
+
pointData: pointData,
|
|
304
|
+
pointP: pointP,
|
|
305
|
+
isLegend: isLegend
|
|
306
|
+
})
|
|
307
|
+
]
|
|
308
|
+
})
|
|
309
|
+
]
|
|
310
|
+
}, nodeSetting?.showType + JSON.stringify(config));
|
|
311
|
+
};
|
|
312
|
+
const composite_MultipleLine = /*#__PURE__*/ memo(MultipleLine);
|
|
313
|
+
export { composite_MultipleLine as default };
|
|
@@ -22,6 +22,10 @@ const NodeGeom = ({ pointData, pointP, isLegend = true })=>/*#__PURE__*/ jsxs(Fr
|
|
|
22
22
|
name: "node",
|
|
23
23
|
visible: false
|
|
24
24
|
}),
|
|
25
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
26
|
+
name: "groupName",
|
|
27
|
+
visible: false
|
|
28
|
+
}),
|
|
25
29
|
isLegend && /*#__PURE__*/ jsx(Legend, {
|
|
26
30
|
name: "color",
|
|
27
31
|
visible: false
|