@publishfx/publish-chart 1.3.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/README.md +143 -0
- package/dist/adapters/DataAdapter.d.ts +33 -0
- package/dist/adapters/DataAdapter.js +75 -0
- package/dist/adapters/TypeAdapter.d.ts +40 -0
- package/dist/adapters/TypeAdapter.js +26 -0
- package/dist/components/base/BarChart.d.ts +7 -0
- package/dist/components/base/BarChart.js +362 -0
- package/dist/components/base/BarChart.lazy.d.ts +5 -0
- package/dist/components/base/BarChart.lazy.js +2 -0
- package/dist/components/base/LineChart.d.ts +7 -0
- package/dist/components/base/LineChart.js +321 -0
- package/dist/components/base/LineChart.lazy.d.ts +5 -0
- package/dist/components/base/LineChart.lazy.js +2 -0
- package/dist/components/composite/BarLineAdapter.d.ts +22 -0
- package/dist/components/composite/BarLineAdapter.js +61 -0
- package/dist/components/composite/BarLineAdapter.lazy.d.ts +5 -0
- package/dist/components/composite/BarLineAdapter.lazy.js +2 -0
- package/dist/components/composite/BarLineChart.d.ts +7 -0
- package/dist/components/composite/BarLineChart.js +255 -0
- package/dist/components/composite/BarLineChart.lazy.d.ts +5 -0
- package/dist/components/composite/BarLineChart.lazy.js +2 -0
- package/dist/components/composite/BarLineCompareWeekend.d.ts +10 -0
- package/dist/components/composite/BarLineCompareWeekend.js +502 -0
- package/dist/components/composite/GroupBarLine.d.ts +11 -0
- package/dist/components/composite/GroupBarLine.js +546 -0
- package/dist/components/composite/GroupBarLine.lazy.d.ts +5 -0
- package/dist/components/composite/GroupBarLine.lazy.js +2 -0
- package/dist/components/composite/GroupCompare.d.ts +10 -0
- package/dist/components/composite/GroupCompare.js +620 -0
- package/dist/components/shared/AuxiliaryLine.d.ts +8 -0
- package/dist/components/shared/AuxiliaryLine.js +64 -0
- package/dist/components/shared/NodeDetail.d.ts +9 -0
- package/dist/components/shared/NodeDetail.js +110 -0
- package/dist/components/shared/NodeGeom.d.ts +23 -0
- package/dist/components/shared/NodeGeom.js +35 -0
- package/dist/components/shared/NodePopover.d.ts +22 -0
- package/dist/components/shared/NodePopover.js +41 -0
- package/dist/components/shared/NodePopoverContent.d.ts +15 -0
- package/dist/components/shared/NodePopoverContent.js +85 -0
- package/dist/components/shared/XAxisBackground.d.ts +31 -0
- package/dist/components/shared/XAxisBackground.js +93 -0
- package/dist/core/ChartConfig.d.ts +48 -0
- package/dist/core/ChartConfig.js +152 -0
- package/dist/core/ChartContext.d.ts +49 -0
- package/dist/core/ChartContext.js +31 -0
- package/dist/core/ChartTypes.d.ts +119 -0
- package/dist/core/ChartTypes.js +0 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +21 -0
- package/dist/services/DataTransformService.d.ts +22 -0
- package/dist/services/DataTransformService.js +29 -0
- package/dist/services/FormatterService.d.ts +24 -0
- package/dist/services/FormatterService.js +22 -0
- package/dist/utils/__tests__/formatters.test.d.ts +1 -0
- package/dist/utils/__tests__/formatters.test.js +333 -0
- package/dist/utils/chartHelpers.d.ts +52 -0
- package/dist/utils/chartHelpers.js +112 -0
- package/dist/utils/dataTransform.d.ts +12 -0
- package/dist/utils/dataTransform.js +64 -0
- package/dist/utils/formatters.d.ts +37 -0
- package/dist/utils/formatters.js +127 -0
- package/dist/utils/indicatorHelpers.d.ts +16 -0
- package/dist/utils/indicatorHelpers.js +15 -0
- package/dist/utils/lazyHelpers.d.ts +29 -0
- package/dist/utils/lazyHelpers.js +15 -0
- package/package.json +68 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Axis, Chart, Interval, Legend, Line, Tooltip, View } from "bizcharts";
|
|
4
|
+
import lib from "@antv/data-set/lib";
|
|
5
|
+
import { useChartContext } from "../../core/ChartContext.js";
|
|
6
|
+
import { calculateBarWidth, getAxisFormat, getAxisHorPaddingByText, getChartKey } from "../../utils/chartHelpers.js";
|
|
7
|
+
import { getIndicatorName } from "../../utils/indicatorHelpers.js";
|
|
8
|
+
import AuxiliaryLine from "../shared/AuxiliaryLine.js";
|
|
9
|
+
import XAxisBackground from "../shared/XAxisBackground.js";
|
|
10
|
+
import { NodeDetail } from "../shared/NodeDetail.js";
|
|
11
|
+
import { NodeGeom } from "../shared/NodeGeom.js";
|
|
12
|
+
const newThemeColors = [
|
|
13
|
+
"#5B8FF9",
|
|
14
|
+
"#5AD8A6",
|
|
15
|
+
"#5D7092",
|
|
16
|
+
"#F6BD16",
|
|
17
|
+
"#6F5EF9",
|
|
18
|
+
"#6DC8EC",
|
|
19
|
+
"#945FB9",
|
|
20
|
+
"#FF9845",
|
|
21
|
+
"#1E9493",
|
|
22
|
+
"#FF99C3",
|
|
23
|
+
"#8CD85A",
|
|
24
|
+
"#FE765E",
|
|
25
|
+
"#67A1FF",
|
|
26
|
+
"#D85ACB",
|
|
27
|
+
"#F95B8F"
|
|
28
|
+
];
|
|
29
|
+
const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "groupType", indicatorMap, config, auxiliaryLineData, onChartClick = ()=>{}, highlightDate = [], nodeSetting = {
|
|
30
|
+
showType: 0,
|
|
31
|
+
type: []
|
|
32
|
+
} })=>{
|
|
33
|
+
const { formatter, dataTransform, config: contextConfig } = useChartContext();
|
|
34
|
+
const safeIndicatorMap = indicatorMap || contextConfig.indicatorMap || {};
|
|
35
|
+
const yAxis = "groupValue";
|
|
36
|
+
const [paddingBottom, setPaddingBottom] = useState(60);
|
|
37
|
+
const { isDataTag = true, isLegend = true, isCombineDataTag = true, isDescend = false, isClickable = false, isHighlight = true } = config || {};
|
|
38
|
+
const ds = new lib();
|
|
39
|
+
const dv = ds.createView().source(data);
|
|
40
|
+
const tdv = ds.createView().source(data);
|
|
41
|
+
const [paddingTop, setPaddingTop] = useState(20);
|
|
42
|
+
const [mainBarSize, setMainBarSize] = useState(void 0);
|
|
43
|
+
if ("" !== y) dv.transform({
|
|
44
|
+
type: "map",
|
|
45
|
+
callback: (row)=>{
|
|
46
|
+
row[yAxis] = "" !== row[yAxis] ? +row[yAxis] : "-";
|
|
47
|
+
return row;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
tdv.transform({
|
|
51
|
+
type: "map",
|
|
52
|
+
callback: (row)=>{
|
|
53
|
+
row[yAxis] = "" !== row[yAxis] ? +row[yAxis] : "-";
|
|
54
|
+
return row;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
tdv.transform({
|
|
58
|
+
type: "filter",
|
|
59
|
+
callback: (row)=>!row.isCombine
|
|
60
|
+
});
|
|
61
|
+
tdv.transform({
|
|
62
|
+
type: "filter",
|
|
63
|
+
callback: (row)=>"-" !== row[yAxis]
|
|
64
|
+
});
|
|
65
|
+
tdv.transform({
|
|
66
|
+
type: "aggregate",
|
|
67
|
+
fields: [
|
|
68
|
+
yAxis
|
|
69
|
+
],
|
|
70
|
+
groupBy: [
|
|
71
|
+
x
|
|
72
|
+
],
|
|
73
|
+
operations: [
|
|
74
|
+
"sum"
|
|
75
|
+
],
|
|
76
|
+
as: [
|
|
77
|
+
"total"
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
if (isDescend) tdv.transform({
|
|
81
|
+
type: "sort",
|
|
82
|
+
callback: (a, b)=>b.total - a.total
|
|
83
|
+
});
|
|
84
|
+
const sortData = tdv.rows.map((item)=>item[x]);
|
|
85
|
+
const [chartWidth, setChatWidth] = useState(0);
|
|
86
|
+
const [chartOffset, setChartOffset] = useState(0);
|
|
87
|
+
let transformData = dv.rows;
|
|
88
|
+
const legendMap = {};
|
|
89
|
+
transformData = transformData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap));
|
|
90
|
+
const leftData = transformData.filter((v)=>!v.isCombine);
|
|
91
|
+
let rightData = transformData.filter((v)=>v.isCombine);
|
|
92
|
+
const colors = [
|
|
93
|
+
"#FE765E",
|
|
94
|
+
"#67A1FF",
|
|
95
|
+
"#D85ACB"
|
|
96
|
+
];
|
|
97
|
+
if (0 === rightData.length) rightData = [
|
|
98
|
+
...leftData
|
|
99
|
+
];
|
|
100
|
+
const rightLegendValues = Array.from(new Set(rightData.map((v)=>v.groupType)));
|
|
101
|
+
const rightLegendItem = rightLegendValues.map((v, i)=>({
|
|
102
|
+
id: `${v}_line`,
|
|
103
|
+
name: getIndicatorName(safeIndicatorMap, v),
|
|
104
|
+
value: v,
|
|
105
|
+
marker: {
|
|
106
|
+
symbol: "hyphen",
|
|
107
|
+
style: {
|
|
108
|
+
stroke: colors[i],
|
|
109
|
+
r: 5,
|
|
110
|
+
lineWidth: 3
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
checked: legendMap[`${v}_line`] || false
|
|
114
|
+
}));
|
|
115
|
+
const leftValueArr = leftData.filter((v)=>"-" !== v[yAxis]).map((v)=>v["total"]);
|
|
116
|
+
const maxLeft = Math.max(...leftValueArr?.length ? leftValueArr : [
|
|
117
|
+
0
|
|
118
|
+
]);
|
|
119
|
+
const rightValueArr = rightData.filter((v)=>"-" !== v[yAxis]).map((v)=>+v[yAxis]);
|
|
120
|
+
const maxRight = Math.max(...rightValueArr?.length ? rightValueArr : [
|
|
121
|
+
0
|
|
122
|
+
]);
|
|
123
|
+
const leftAuxi = auxiliaryLineData?.filter((item)=>"left" === item.axis || !Object.prototype.hasOwnProperty.call(item, "axis"));
|
|
124
|
+
const rightAuxi = auxiliaryLineData?.filter((item)=>"right" === item.axis);
|
|
125
|
+
const maxYLeft = Math.max(maxLeft, leftAuxi && Math.max(...leftAuxi.map((item)=>+item.value)) || 0);
|
|
126
|
+
const maxYRightValue = Math.max(maxRight, rightAuxi && Math.max(...rightAuxi.map((item)=>+item.value)) || 0);
|
|
127
|
+
const maxYRight = maxYRightValue !== maxRight && rightAuxi && rightAuxi.length > 0 ? 1.2 * Math.max(...rightAuxi.map((item)=>+item.value)) : maxYRightValue;
|
|
128
|
+
const scale = {
|
|
129
|
+
groupValue: {
|
|
130
|
+
type: "linear-strict",
|
|
131
|
+
min: 0,
|
|
132
|
+
nice: true,
|
|
133
|
+
max: maxYLeft
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
useEffect(()=>{
|
|
137
|
+
let oldOffset = maxYLeft > maxYRight ? 35 : 20;
|
|
138
|
+
if (2 == nodeSetting.showType) oldOffset = 35;
|
|
139
|
+
setPaddingTop(oldOffset);
|
|
140
|
+
}, [
|
|
141
|
+
maxLeft,
|
|
142
|
+
maxYLeft
|
|
143
|
+
]);
|
|
144
|
+
useEffect(()=>{
|
|
145
|
+
if (nodeSetting?.showType === 2 && chartWidth / leftData.length > 30) if (leftData.some((item)=>item?.nodeLen > 2)) setPaddingBottom(55);
|
|
146
|
+
else leftData.some((item)=>item?.nodeLen === 2) ? setPaddingBottom(40) : setPaddingBottom(25);
|
|
147
|
+
else setPaddingBottom(50);
|
|
148
|
+
}, [
|
|
149
|
+
chartWidth,
|
|
150
|
+
leftData,
|
|
151
|
+
nodeSetting
|
|
152
|
+
]);
|
|
153
|
+
const offsetLeft = getAxisHorPaddingByText(maxYLeft, safeIndicatorMap, y);
|
|
154
|
+
const offsetRight = rightData.length > 0 && void 0 !== maxYRight ? getAxisHorPaddingByText(maxYRight, safeIndicatorMap, rightData[0][legend]) : 10;
|
|
155
|
+
const scaleAuxiliary = {
|
|
156
|
+
groupValue: {
|
|
157
|
+
type: "linear-strict",
|
|
158
|
+
min: 0,
|
|
159
|
+
nice: true,
|
|
160
|
+
max: maxYRight
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
let chartIns;
|
|
164
|
+
if (isDescend) {
|
|
165
|
+
leftData.sort((a, b)=>b["total"] - a["total"]);
|
|
166
|
+
rightData.sort((a, b)=>sortData.indexOf(a[x]) - sortData.indexOf(b[x]));
|
|
167
|
+
} else rightData.sort((a, b)=>sortData.indexOf(a[x]) - sortData.indexOf(b[x]));
|
|
168
|
+
const legendValues = Array.from(new Set(leftData.map((v)=>v.groupType)));
|
|
169
|
+
const legendItem = legendValues.map((v, i)=>({
|
|
170
|
+
id: `${v}_bar`,
|
|
171
|
+
name: v === y ? getIndicatorName(safeIndicatorMap, y) : v,
|
|
172
|
+
value: v,
|
|
173
|
+
marker: {
|
|
174
|
+
symbol: "square",
|
|
175
|
+
style: {
|
|
176
|
+
fill: newThemeColors[i]
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
checked: legendMap[`${v}_bar`] || false
|
|
180
|
+
}));
|
|
181
|
+
const topLabel = {};
|
|
182
|
+
const [pointP, setPointP] = useState({
|
|
183
|
+
x: 0,
|
|
184
|
+
y: 0
|
|
185
|
+
});
|
|
186
|
+
const [pointData, setPointData] = useState({
|
|
187
|
+
info: [],
|
|
188
|
+
infosCompare: []
|
|
189
|
+
});
|
|
190
|
+
useEffect(()=>{
|
|
191
|
+
setPointP({
|
|
192
|
+
x: 0,
|
|
193
|
+
y: 0
|
|
194
|
+
});
|
|
195
|
+
setPointData({
|
|
196
|
+
info: [],
|
|
197
|
+
infosCompare: []
|
|
198
|
+
});
|
|
199
|
+
}, [
|
|
200
|
+
data
|
|
201
|
+
]);
|
|
202
|
+
const filterFn = useMemo(()=>(item)=>highlightDate.includes(item.groupName) ?? false, [
|
|
203
|
+
highlightDate
|
|
204
|
+
]);
|
|
205
|
+
return /*#__PURE__*/ jsxs(Chart, {
|
|
206
|
+
height: height,
|
|
207
|
+
padding: [
|
|
208
|
+
paddingTop,
|
|
209
|
+
offsetRight,
|
|
210
|
+
paddingBottom,
|
|
211
|
+
offsetLeft
|
|
212
|
+
],
|
|
213
|
+
scale: scale,
|
|
214
|
+
data: leftData,
|
|
215
|
+
autoFit: true,
|
|
216
|
+
forceUpdate: false,
|
|
217
|
+
onGetG2Instance: (chart)=>{
|
|
218
|
+
chartIns = chart;
|
|
219
|
+
},
|
|
220
|
+
onPlotClick: (e, chart)=>{
|
|
221
|
+
if (onChartClick) {
|
|
222
|
+
const value = chart.getTooltipItems({
|
|
223
|
+
x: e.x,
|
|
224
|
+
y: e.y
|
|
225
|
+
});
|
|
226
|
+
if (value && value[0]) onChartClick(value[0]);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
onPointMouseover: (e)=>{
|
|
230
|
+
if (1 === nodeSetting.showType) {
|
|
231
|
+
setPointP({
|
|
232
|
+
x: e.data.x,
|
|
233
|
+
y: e.data.y
|
|
234
|
+
});
|
|
235
|
+
setPointData(e.data.data.nodeInfos);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
onAfterrender: (chart)=>{
|
|
239
|
+
if (2 == nodeSetting.showType) {
|
|
240
|
+
setChatWidth(chart.view?.coordinateBBox?.width || 0);
|
|
241
|
+
setChartOffset(chart.view?.coordinateBBox?.x || 0);
|
|
242
|
+
}
|
|
243
|
+
const estimatedBarWidth = calculateBarWidth(chart, leftData, x, 0.5);
|
|
244
|
+
if (void 0 !== estimatedBarWidth) setMainBarSize(estimatedBarWidth);
|
|
245
|
+
},
|
|
246
|
+
children: [
|
|
247
|
+
/*#__PURE__*/ jsx(XAxisBackground, {
|
|
248
|
+
x: x,
|
|
249
|
+
data: leftData,
|
|
250
|
+
isHighlight: isHighlight,
|
|
251
|
+
filterFn: filterFn,
|
|
252
|
+
dataLength: leftData.length,
|
|
253
|
+
mainBarSize: mainBarSize
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ jsx(Interval, {
|
|
256
|
+
adjust: [
|
|
257
|
+
{
|
|
258
|
+
type: "stack"
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
color: [
|
|
262
|
+
legend,
|
|
263
|
+
newThemeColors
|
|
264
|
+
],
|
|
265
|
+
position: `${x}*${yAxis}`,
|
|
266
|
+
style: {
|
|
267
|
+
cursor: isClickable ? "pointer" : "default"
|
|
268
|
+
},
|
|
269
|
+
label: [
|
|
270
|
+
`${legend}*total*${x}*${yAxis}`,
|
|
271
|
+
(_v, total, xVal, yVal)=>{
|
|
272
|
+
let renderFlag = false;
|
|
273
|
+
if ("-" === yVal) return null;
|
|
274
|
+
if (!topLabel[xVal]) {
|
|
275
|
+
renderFlag = true;
|
|
276
|
+
topLabel[xVal] = true;
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
content: isDataTag && renderFlag ? formatter.formatIndicator(total, safeIndicatorMap[y]) : "",
|
|
280
|
+
style: {
|
|
281
|
+
fontWeight: "bold"
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
288
|
+
shared: true,
|
|
289
|
+
showCrosshairs: true,
|
|
290
|
+
children: (title, items)=>{
|
|
291
|
+
const { groupItems, speItems, combineItems } = (items || []).reduce((acc, item)=>{
|
|
292
|
+
if (item.data.isCombine) acc.combineItems.push(item);
|
|
293
|
+
else if ("-" === item.value) acc.speItems.push(item);
|
|
294
|
+
else acc.groupItems.push(item);
|
|
295
|
+
return acc;
|
|
296
|
+
}, {
|
|
297
|
+
groupItems: [],
|
|
298
|
+
speItems: [],
|
|
299
|
+
combineItems: []
|
|
300
|
+
});
|
|
301
|
+
const sortItems = [
|
|
302
|
+
...groupItems.sort((a, b)=>Number(b.value) - Number(a.value)),
|
|
303
|
+
...speItems,
|
|
304
|
+
...combineItems
|
|
305
|
+
];
|
|
306
|
+
let AuxiIndicatorName = "";
|
|
307
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
308
|
+
style: {
|
|
309
|
+
padding: "10px 0"
|
|
310
|
+
},
|
|
311
|
+
children: [
|
|
312
|
+
title,
|
|
313
|
+
sortItems && /*#__PURE__*/ jsxs(Fragment, {
|
|
314
|
+
children: [
|
|
315
|
+
/*#__PURE__*/ jsx("div", {
|
|
316
|
+
style: {
|
|
317
|
+
marginTop: "10px"
|
|
318
|
+
},
|
|
319
|
+
children: sortItems.map((it, index)=>{
|
|
320
|
+
if (it.data.isCombine) AuxiIndicatorName = it.name;
|
|
321
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
322
|
+
style: {
|
|
323
|
+
display: "flex",
|
|
324
|
+
justifyContent: "space-between",
|
|
325
|
+
marginBottom: "10px"
|
|
326
|
+
},
|
|
327
|
+
children: [
|
|
328
|
+
/*#__PURE__*/ jsxs("span", {
|
|
329
|
+
children: [
|
|
330
|
+
/*#__PURE__*/ jsx("span", {
|
|
331
|
+
style: {
|
|
332
|
+
width: "8px",
|
|
333
|
+
height: "8px",
|
|
334
|
+
backgroundColor: it.color,
|
|
335
|
+
display: "inline-block",
|
|
336
|
+
borderRadius: "50%",
|
|
337
|
+
marginRight: "8px"
|
|
338
|
+
}
|
|
339
|
+
}),
|
|
340
|
+
it.name === y ? getIndicatorName(safeIndicatorMap, y) : it.data.isCombine ? getIndicatorName(safeIndicatorMap, it.name) : it.name,
|
|
341
|
+
":"
|
|
342
|
+
]
|
|
343
|
+
}),
|
|
344
|
+
/*#__PURE__*/ jsxs("span", {
|
|
345
|
+
style: {
|
|
346
|
+
fontWeight: "bold",
|
|
347
|
+
paddingLeft: "10px"
|
|
348
|
+
},
|
|
349
|
+
children: [
|
|
350
|
+
it.data.isCombine ? formatter.formatIndicator(it.value, safeIndicatorMap[it.name]) : formatter.formatIndicator(it.value, safeIndicatorMap[y]),
|
|
351
|
+
!it.data.isCombine && !isClickable && /*#__PURE__*/ jsxs(Fragment, {
|
|
352
|
+
children: [
|
|
353
|
+
"(",
|
|
354
|
+
(100 * Number(it.data.percent)).toFixed(2),
|
|
355
|
+
"%)"
|
|
356
|
+
]
|
|
357
|
+
}),
|
|
358
|
+
it.data.isCombine && /*#__PURE__*/ jsx(Fragment, {
|
|
359
|
+
children: "\xa0\xa0"
|
|
360
|
+
})
|
|
361
|
+
]
|
|
362
|
+
})
|
|
363
|
+
]
|
|
364
|
+
}, index);
|
|
365
|
+
})
|
|
366
|
+
}),
|
|
367
|
+
auxiliaryLineData && auxiliaryLineData.map((item, index)=>/*#__PURE__*/ jsxs("div", {
|
|
368
|
+
style: {
|
|
369
|
+
marginLeft: "16px",
|
|
370
|
+
marginTop: "10px",
|
|
371
|
+
display: "flex",
|
|
372
|
+
justifyContent: "space-between"
|
|
373
|
+
},
|
|
374
|
+
children: [
|
|
375
|
+
/*#__PURE__*/ jsxs("div", {
|
|
376
|
+
style: {
|
|
377
|
+
marginRight: "8px"
|
|
378
|
+
},
|
|
379
|
+
children: [
|
|
380
|
+
item.name,
|
|
381
|
+
":"
|
|
382
|
+
]
|
|
383
|
+
}),
|
|
384
|
+
/*#__PURE__*/ jsx("div", {
|
|
385
|
+
children: "left" === item.axis ? formatter.formatIndicator(item.value, safeIndicatorMap[y]) : formatter.formatIndicator(item.value, safeIndicatorMap[AuxiIndicatorName])
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
}, index))
|
|
389
|
+
]
|
|
390
|
+
})
|
|
391
|
+
]
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}),
|
|
395
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
396
|
+
name: yAxis,
|
|
397
|
+
position: "left",
|
|
398
|
+
label: {
|
|
399
|
+
formatter: (val)=>getAxisFormat(val, safeIndicatorMap, y)
|
|
400
|
+
}
|
|
401
|
+
}),
|
|
402
|
+
rightData.length > 0 && /*#__PURE__*/ jsxs(Fragment, {
|
|
403
|
+
children: [
|
|
404
|
+
/*#__PURE__*/ jsxs(View, {
|
|
405
|
+
data: rightData,
|
|
406
|
+
scale: scaleAuxiliary,
|
|
407
|
+
padding: 0,
|
|
408
|
+
name: "lineview",
|
|
409
|
+
children: [
|
|
410
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
411
|
+
name: yAxis,
|
|
412
|
+
position: "right",
|
|
413
|
+
label: {
|
|
414
|
+
formatter: (val)=>getAxisFormat(val, safeIndicatorMap, rightData[0][legend])
|
|
415
|
+
}
|
|
416
|
+
}),
|
|
417
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
418
|
+
name: x,
|
|
419
|
+
visible: false
|
|
420
|
+
}),
|
|
421
|
+
/*#__PURE__*/ jsx(Line, {
|
|
422
|
+
position: `${x}*${yAxis}`,
|
|
423
|
+
color: [
|
|
424
|
+
legend,
|
|
425
|
+
colors
|
|
426
|
+
],
|
|
427
|
+
label: [
|
|
428
|
+
`${legend}*${yAxis}`,
|
|
429
|
+
(name, value)=>{
|
|
430
|
+
const content = isCombineDataTag ? formatter.formatIndicator(value, safeIndicatorMap[name]) : null;
|
|
431
|
+
return {
|
|
432
|
+
content: content || "",
|
|
433
|
+
style: {
|
|
434
|
+
fontWeight: "bold"
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
})
|
|
440
|
+
]
|
|
441
|
+
}),
|
|
442
|
+
rightAuxi && rightAuxi.length > 0 && /*#__PURE__*/ jsxs(View, {
|
|
443
|
+
data: rightData,
|
|
444
|
+
scale: scaleAuxiliary,
|
|
445
|
+
padding: [
|
|
446
|
+
0,
|
|
447
|
+
-offsetRight,
|
|
448
|
+
0,
|
|
449
|
+
0
|
|
450
|
+
],
|
|
451
|
+
children: [
|
|
452
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
453
|
+
name: yAxis,
|
|
454
|
+
visible: false
|
|
455
|
+
}),
|
|
456
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
457
|
+
name: x,
|
|
458
|
+
visible: false
|
|
459
|
+
}),
|
|
460
|
+
/*#__PURE__*/ jsx(Interval, {
|
|
461
|
+
position: `${x}*${yAxis}`,
|
|
462
|
+
visible: false
|
|
463
|
+
}),
|
|
464
|
+
rightAuxi.map((item, index)=>/*#__PURE__*/ jsx(AuxiliaryLine, {
|
|
465
|
+
axis: "right",
|
|
466
|
+
name: item.name,
|
|
467
|
+
value: item.value
|
|
468
|
+
}, index))
|
|
469
|
+
]
|
|
470
|
+
}, offsetRight)
|
|
471
|
+
]
|
|
472
|
+
}),
|
|
473
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
474
|
+
custom: true,
|
|
475
|
+
name: legend,
|
|
476
|
+
position: 2 === nodeSetting.showType ? "top" : "bottom",
|
|
477
|
+
itemHeight: 14,
|
|
478
|
+
visible: isLegend,
|
|
479
|
+
items: [
|
|
480
|
+
...legendItem,
|
|
481
|
+
...rightLegendItem
|
|
482
|
+
],
|
|
483
|
+
onChange: (ev)=>{
|
|
484
|
+
for(const key in topLabel)topLabel[key] = false;
|
|
485
|
+
const { item } = ev;
|
|
486
|
+
const { id } = item;
|
|
487
|
+
const checked = !item.unchecked;
|
|
488
|
+
legendMap[id] = checked;
|
|
489
|
+
const chartType = id.split("_")[1];
|
|
490
|
+
if ("line" === chartType) {
|
|
491
|
+
const view = chartIns.views[1];
|
|
492
|
+
view.filter(legend, (val)=>false !== legendMap[`${val}_line`]);
|
|
493
|
+
view.render(true);
|
|
494
|
+
}
|
|
495
|
+
if ("bar" === chartType) chartIns.filter(legend, (val)=>false !== legendMap[`${val}_bar`]);
|
|
496
|
+
chartIns.render(true);
|
|
497
|
+
}
|
|
498
|
+
}),
|
|
499
|
+
leftAuxi && leftAuxi.length > 0 && /*#__PURE__*/ jsxs(View, {
|
|
500
|
+
data: leftData,
|
|
501
|
+
scale: scale,
|
|
502
|
+
padding: [
|
|
503
|
+
0,
|
|
504
|
+
0,
|
|
505
|
+
0,
|
|
506
|
+
-offsetLeft
|
|
507
|
+
],
|
|
508
|
+
name: "barview",
|
|
509
|
+
children: [
|
|
510
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
511
|
+
name: yAxis,
|
|
512
|
+
visible: false
|
|
513
|
+
}),
|
|
514
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
515
|
+
name: x,
|
|
516
|
+
visible: false
|
|
517
|
+
}),
|
|
518
|
+
/*#__PURE__*/ jsx(Interval, {
|
|
519
|
+
position: `${x}*${yAxis}`,
|
|
520
|
+
visible: false
|
|
521
|
+
}),
|
|
522
|
+
leftAuxi.map((item, index)=>/*#__PURE__*/ jsx(AuxiliaryLine, {
|
|
523
|
+
name: item.name,
|
|
524
|
+
value: item.value
|
|
525
|
+
}, index))
|
|
526
|
+
]
|
|
527
|
+
}, offsetLeft),
|
|
528
|
+
dv.rows.some((item)=>item?.nodeInfos?.info?.length > 0 || item?.nodeInfos?.infosCompare?.length > 0) ? /*#__PURE__*/ jsx(Fragment, {
|
|
529
|
+
children: 1 == nodeSetting.showType && NodeGeom ? /*#__PURE__*/ jsx(NodeGeom, {
|
|
530
|
+
pointData: pointData,
|
|
531
|
+
pointP: pointP
|
|
532
|
+
}) : 2 == nodeSetting.showType && NodeDetail ? 0 == chartOffset || chartOffset ? /*#__PURE__*/ jsx(NodeDetail, {
|
|
533
|
+
chartWidth: chartWidth,
|
|
534
|
+
chartOffset: chartOffset,
|
|
535
|
+
dvRows: dv.rows.filter((item)=>!item.isCombine),
|
|
536
|
+
ratio: 1
|
|
537
|
+
}) : null : null
|
|
538
|
+
}) : null
|
|
539
|
+
]
|
|
540
|
+
}, getChartKey({
|
|
541
|
+
config,
|
|
542
|
+
nodeSetting
|
|
543
|
+
}));
|
|
544
|
+
};
|
|
545
|
+
const composite_GroupBarLine = /*#__PURE__*/ memo(GroupBarLine);
|
|
546
|
+
export { composite_GroupBarLine as default, newThemeColors };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 分组(柱状、折线)对比图组件
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
import type { BaseChartProps } from "../../core/ChartTypes";
|
|
6
|
+
interface GroupCompareProps extends BaseChartProps {
|
|
7
|
+
legend?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.NamedExoticComponent<GroupCompareProps>;
|
|
10
|
+
export default _default;
|