@publishfx/publish-chart 2.1.9 → 2.1.11
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/CHANGELOG.md +15 -0
- package/dist/adapters/DataAdapter.d.ts +1 -0
- package/dist/adapters/DataAdapter.js +2 -6
- package/dist/components/g2/base/G2BarChart.js +2 -3
- package/dist/components/g2/base/G2CombineChart.js +21 -10
- package/dist/components/g2/base/G2LineChart.js +6 -2
- package/dist/components/g2/base/g2Helpers.js +3 -1
- package/dist/components/g2/base/g2combine.js +121 -99
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
**2.1.11** fix(chart): 组合图去掉主轴过滤逻辑,以支持tooltip展示
|
|
2
|
+
- 2026-03-04T20:56:34+08:00 [fix(chart): 组合图去掉主轴过滤逻辑,以支持tooltip展示](http://lf.git.oa.mt/publish_platform/web/publish/commit/215222fb1ae535a52aea475d3a8447cdc61dfa19)
|
|
3
|
+
- 2026-03-04T20:30:34+08:00 [fix(chart): 组合图数据处理逻辑优化](http://lf.git.oa.mt/publish_platform/web/publish/commit/bab29eb2897d1b7b60877c234d8cc14b4d79b9a9)
|
|
4
|
+
- 2026-03-04T20:22:30+08:00 [feat(chart): 柱状图切换指标空白问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/2e37e53f1322968e7a1e384bf148d7fd213fb7c2)
|
|
5
|
+
- 2026-03-04T19:14:10+08:00 [feat(chart): 坐标轴label透明度](http://lf.git.oa.mt/publish_platform/web/publish/commit/47436b58d55a8c770a8374b70cf974db86e4aecc)
|
|
6
|
+
- 2026-03-04T18:25:28+08:00 [feat(chart): 多指标折线图组合图y轴格式化](http://lf.git.oa.mt/publish_platform/web/publish/commit/e1577f958143c2d2e338adb73e4a6ac3193cb08f)
|
|
7
|
+
- 2026-03-04T17:55:18+08:00 [fix(chart): 修复之前异常数据处理导致的组合图分组tooltip数据错误的问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/62982adf8ce4ce3b04cc8fc6703e2fce05b43984)
|
|
8
|
+
- 2026-03-04T17:53:43+08:00 [fix(chart): 组合图折线图触发下钻](http://lf.git.oa.mt/publish_platform/web/publish/commit/51cabfb3e90b990db03b04ab6e6c039d9c7d3239)
|
|
9
|
+
- 2026-03-04T17:34:02+08:00 [fix(chart): 修复剩余数据全为0时的Y轴异常问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/0d64328b1c38b71ad0289579592870fa20bc37b1)
|
|
10
|
+
- 2026-03-04T17:13:55+08:00 [fix(chart): 辅助线分左右,分别影响主、副轴的刻度尺](http://lf.git.oa.mt/publish_platform/web/publish/commit/0c91a39b4fe8ff1b13999766e8f6f90dce85f37e)
|
|
11
|
+
|
|
12
|
+
**2.1.10** fix(chart): 修复剩余数据全为0时的Y轴异常问题
|
|
13
|
+
- 2026-03-04T17:34:02+08:00 [fix(chart): 修复剩余数据全为0时的Y轴异常问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/0d64328b1c38b71ad0289579592870fa20bc37b1)
|
|
14
|
+
- 2026-03-04T17:13:55+08:00 [fix(chart): 辅助线分左右,分别影响主、副轴的刻度尺](http://lf.git.oa.mt/publish_platform/web/publish/commit/0c91a39b4fe8ff1b13999766e8f6f90dce85f37e)
|
|
15
|
+
|
|
1
16
|
**2.1.9** feat(chart): 组合图折线色彩设置
|
|
2
17
|
- 2026-03-04T16:45:43+08:00 [feat(chart): 组合图折线色彩设置](http://lf.git.oa.mt/publish_platform/web/publish/commit/2d456a5bd13fbed534b125a71955e8d18f62bbfc)
|
|
3
18
|
- 2026-03-04T16:42:51+08:00 [feat(chart): 组合图副轴最大值逻辑复原](http://lf.git.oa.mt/publish_platform/web/publish/commit/6a1e758f64f6e7ef202c8089afecdd49580cf133)
|
|
@@ -144,12 +144,8 @@ class DataAdapter {
|
|
|
144
144
|
return row.isCombine;
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
|
-
tdv.
|
|
148
|
-
|
|
149
|
-
callback (row) {
|
|
150
|
-
return !row[config.y] || '-' !== row[config.y];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
147
|
+
console.log('tdv:', tdv.rows);
|
|
148
|
+
console.log('tdv:', tdv.rows);
|
|
153
149
|
if (config.isDescend) tdv.transform({
|
|
154
150
|
type: 'sort',
|
|
155
151
|
callback (a, b) {
|
|
@@ -88,12 +88,11 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
|
|
|
88
88
|
symbol: "square"
|
|
89
89
|
}));
|
|
90
90
|
setLegendItems(items);
|
|
91
|
-
|
|
91
|
+
setActiveIds(items.map((i)=>i.id));
|
|
92
92
|
}, [
|
|
93
93
|
transformedData,
|
|
94
94
|
safeIndicatorMap,
|
|
95
|
-
themeColors
|
|
96
|
-
activeIds.length
|
|
95
|
+
themeColors
|
|
97
96
|
]);
|
|
98
97
|
const filteredData = useMemo(()=>{
|
|
99
98
|
if (!activeIds.length) return transformedData;
|
|
@@ -66,6 +66,7 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
66
66
|
const tooltipContainerRef = useG2TooltipContainer();
|
|
67
67
|
const isGroupRef = useRef(isGroup);
|
|
68
68
|
const [isOldData, setIsOldData] = useState(false);
|
|
69
|
+
const currentTooltipTitleRef = useRef(null);
|
|
69
70
|
isGroupRef.current = isGroup;
|
|
70
71
|
console.log("G2CombineChart props:", data, x, y, z, indicators, legend, config, nodeSetting);
|
|
71
72
|
const themeColors = contextConfig?.theme?.colors || [];
|
|
@@ -85,6 +86,7 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
85
86
|
let result = transformDataToGroupBarLineFormat(data, x, y, indicators);
|
|
86
87
|
data = result;
|
|
87
88
|
setIsOldData(true);
|
|
89
|
+
console.log('tdv data:', data);
|
|
88
90
|
}
|
|
89
91
|
console.log("G2CombineChart renderG2CombineChart transformedData2:", data);
|
|
90
92
|
const { transformedData, leftData, rightData } = DataAdapter.transform(data, "barLine", {
|
|
@@ -93,7 +95,8 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
93
95
|
y: safeY,
|
|
94
96
|
z,
|
|
95
97
|
isDescend,
|
|
96
|
-
isGroup: isGroupRef.current
|
|
98
|
+
isGroup: isGroupRef.current,
|
|
99
|
+
isOld: !legend
|
|
97
100
|
});
|
|
98
101
|
return {
|
|
99
102
|
transformedData: transformedData.map((item)=>dataTransform.processNodeInfo(item, contextConfig.nodeMap)),
|
|
@@ -125,9 +128,13 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
125
128
|
safeIndicatorMap,
|
|
126
129
|
y
|
|
127
130
|
]);
|
|
128
|
-
const formatLineAxis = useCallback((val)=>
|
|
131
|
+
const formatLineAxis = useCallback((val)=>{
|
|
132
|
+
const indicatorId = indicators?.length > 1 ? '' : safeZ;
|
|
133
|
+
return getAxisFormat(val, safeIndicatorMap, indicatorId);
|
|
134
|
+
}, [
|
|
129
135
|
safeIndicatorMap,
|
|
130
|
-
safeZ
|
|
136
|
+
safeZ,
|
|
137
|
+
indicators
|
|
131
138
|
]);
|
|
132
139
|
useEffect(()=>{
|
|
133
140
|
if (!transformedData.length) {
|
|
@@ -170,7 +177,7 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
170
177
|
if (!activeIds.length) return leftData;
|
|
171
178
|
const result = leftData.filter((d)=>d.groupType ? activeIds.includes(String(d.groupType.replace("_compare", "") + "_" + d.isCombine)) : true);
|
|
172
179
|
if (isGroupRef.current) result.forEach((item)=>{
|
|
173
|
-
item.total = result.filter((d)=>d.groupName === item.groupName).reduce((acc, d)=>acc + d.groupValue, 0);
|
|
180
|
+
item.total = result.filter((d)=>d.groupName === item.groupName).reduce((acc, d)=>acc + d.groupValue === '' ? 0 : d.groupValue, 0);
|
|
174
181
|
});
|
|
175
182
|
return result;
|
|
176
183
|
}, [
|
|
@@ -230,6 +237,7 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
230
237
|
} : void 0,
|
|
231
238
|
indicators,
|
|
232
239
|
tooltipRender: (title, items)=>{
|
|
240
|
+
currentTooltipTitleRef.current = title;
|
|
233
241
|
const container = tooltipContainerRef.current;
|
|
234
242
|
if (!container) return null;
|
|
235
243
|
let safeItems = items.map((i)=>({
|
|
@@ -267,15 +275,18 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
267
275
|
isGroup: isGroupRef.current
|
|
268
276
|
});
|
|
269
277
|
chartRef.current = chart;
|
|
270
|
-
if (onChartClick) chart.on("
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
title
|
|
274
|
-
|
|
278
|
+
if (onChartClick) chart.on("plot:click", (_e)=>{
|
|
279
|
+
const tooltipTitle = currentTooltipTitleRef.current;
|
|
280
|
+
if (null != tooltipTitle) {
|
|
281
|
+
console.log('使用 tooltip title 触发下钻:', tooltipTitle);
|
|
282
|
+
onChartClick({
|
|
283
|
+
title: tooltipTitle
|
|
284
|
+
});
|
|
285
|
+
}
|
|
275
286
|
});
|
|
276
287
|
return ()=>{
|
|
277
288
|
if (chartRef.current) {
|
|
278
|
-
chartRef.current.off("
|
|
289
|
+
chartRef.current.off("plot:click");
|
|
279
290
|
chartRef.current.destroy();
|
|
280
291
|
chartRef.current = null;
|
|
281
292
|
}
|
|
@@ -76,9 +76,13 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
|
|
|
76
76
|
safeY,
|
|
77
77
|
auxiliaryLineData
|
|
78
78
|
]);
|
|
79
|
-
const formatAxis = useCallback((val)=>
|
|
79
|
+
const formatAxis = useCallback((val)=>{
|
|
80
|
+
const indicatorId = indicators?.length > 1 ? '' : safeLegend;
|
|
81
|
+
return getAxisFormat(val, safeIndicatorMap, indicatorId);
|
|
82
|
+
}, [
|
|
80
83
|
safeIndicatorMap,
|
|
81
|
-
safeLegend
|
|
84
|
+
safeLegend,
|
|
85
|
+
indicators
|
|
82
86
|
]);
|
|
83
87
|
useEffect(()=>{
|
|
84
88
|
if (!transformedData.length) {
|
|
@@ -82,6 +82,7 @@ function applyAxisX(mark, options = {}) {
|
|
|
82
82
|
},
|
|
83
83
|
labelAlign: 'horizontal',
|
|
84
84
|
labelDx: (_datum, _index, _data)=>0,
|
|
85
|
+
labelOpacity: 0.6,
|
|
85
86
|
...axisFilter && {
|
|
86
87
|
tickFilter: axisFilter('tick'),
|
|
87
88
|
labelFilter: axisFilter('label')
|
|
@@ -96,6 +97,7 @@ function applyAxisY(mark, options = {}) {
|
|
|
96
97
|
mark.axis('y', {
|
|
97
98
|
title,
|
|
98
99
|
labelAutoRotate,
|
|
100
|
+
labelOpacity: 0.6,
|
|
99
101
|
grid,
|
|
100
102
|
gridStroke,
|
|
101
103
|
gridLineWidth,
|
|
@@ -263,7 +265,7 @@ function applyNodeData(view, nodeData, x, y) {
|
|
|
263
265
|
return nodeList;
|
|
264
266
|
}
|
|
265
267
|
function adjustDomainMax(domainMin, domainMax) {
|
|
266
|
-
return domainMax === domainMin ? domainMin > 0 ? 1.1 * domainMax : domainMax +
|
|
268
|
+
return domainMax === domainMin ? domainMin > 0 ? 1.1 * domainMax : domainMax + 1000 : domainMax;
|
|
267
269
|
}
|
|
268
270
|
const sortByIndicators = (arr, indicators)=>arr.sort((a, b)=>{
|
|
269
271
|
const baseA = a.split('_')[0];
|
|
@@ -38,11 +38,16 @@ function renderG2CombineChart(container, options) {
|
|
|
38
38
|
console.log('renderG2CombineChart interval data:', intervalData);
|
|
39
39
|
const intervalMaxY = intervalData.reduce((max, item)=>{
|
|
40
40
|
const key = isGroup ? "total" : BAR_Y_FIELD;
|
|
41
|
+
console.log('tdv item:', key, item[key], intervalData);
|
|
42
|
+
if ('-' === item[key] || void 0 === item[key] || null === item[key] || '' === item[key]) return max;
|
|
41
43
|
return Math.max(max, item[key]);
|
|
42
44
|
}, 0);
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
45
|
+
console.log('tdv:', intervalMaxY);
|
|
46
|
+
const auxLeftValues = auxiliaryLineData?.length ? auxiliaryLineData.filter((item)=>'left' === item.axis).map((item)=>item.value) : [];
|
|
47
|
+
const maxAuxLeft = auxLeftValues.length ? Math.max(...auxLeftValues) : 0;
|
|
48
|
+
const auxRightValues = auxiliaryLineData?.length ? auxiliaryLineData.filter((item)=>'right' === item.axis).map((item)=>item.value) : [];
|
|
49
|
+
const maxAuxRight = auxRightValues.length ? Math.max(...auxRightValues) : 0;
|
|
50
|
+
const finalIntervalMax = Math.max(intervalMaxY, maxAuxLeft);
|
|
46
51
|
const interval = view.interval().data(intervalData).encode("x", x).encode("y", BAR_Y_FIELD).encode("color", "groupType").transform(isGroup ? {
|
|
47
52
|
type: 'stackY',
|
|
48
53
|
reverse: true
|
|
@@ -102,7 +107,8 @@ function renderG2CombineChart(container, options) {
|
|
|
102
107
|
0,
|
|
103
108
|
0
|
|
104
109
|
],
|
|
105
|
-
labelFormatter: formatAxis
|
|
110
|
+
labelFormatter: formatAxis,
|
|
111
|
+
labelOpacity: 0.6
|
|
106
112
|
});
|
|
107
113
|
console.log('tooltip:', barColor, isCompare);
|
|
108
114
|
interval.tooltip({
|
|
@@ -118,7 +124,8 @@ function renderG2CombineChart(container, options) {
|
|
|
118
124
|
channel: Y_AXIS_FIELD,
|
|
119
125
|
color: themeColors[index % themeColors.length] ?? themeColors[0] ?? "#5B8FF9",
|
|
120
126
|
percent: `${(100 * Number(datum.percent)).toFixed(2)}%`,
|
|
121
|
-
isCombine: false
|
|
127
|
+
isCombine: false,
|
|
128
|
+
x: datum[x]
|
|
122
129
|
};
|
|
123
130
|
}
|
|
124
131
|
].filter(Boolean) : [
|
|
@@ -138,7 +145,8 @@ function renderG2CombineChart(container, options) {
|
|
|
138
145
|
indicatorId: datum['groupType'].replace('_compare', ''),
|
|
139
146
|
channel: Y_AXIS_FIELD,
|
|
140
147
|
color: barColor || 'transparent',
|
|
141
|
-
isCombine: false
|
|
148
|
+
isCombine: false,
|
|
149
|
+
x: datum[x]
|
|
142
150
|
} : false : false,
|
|
143
151
|
isCompare ? (datum)=>datum.groupType.includes('_compare') ? {
|
|
144
152
|
name: datum['groupType'].replace('_compare', '_change'),
|
|
@@ -146,7 +154,8 @@ function renderG2CombineChart(container, options) {
|
|
|
146
154
|
value: datum?.change,
|
|
147
155
|
isChange: true,
|
|
148
156
|
color: 'transparent',
|
|
149
|
-
isCombine: false
|
|
157
|
+
isCombine: false,
|
|
158
|
+
x: datum[x]
|
|
150
159
|
} : false : false
|
|
151
160
|
].filter(Boolean)
|
|
152
161
|
});
|
|
@@ -154,16 +163,22 @@ function renderG2CombineChart(container, options) {
|
|
|
154
163
|
...item,
|
|
155
164
|
[LINE_Y_FIELD]: item[Y_AXIS_FIELD]
|
|
156
165
|
}));
|
|
157
|
-
console.log('renderG2CombineChart: line data:',
|
|
166
|
+
console.log('renderG2CombineChart: line data:', data);
|
|
158
167
|
const compareLineData = data.filter((item)=>item.isCombine && item.groupType.includes('_compare')).filter((item)=>'' !== item[Y_AXIS_FIELD]).map((item)=>({
|
|
159
168
|
...item,
|
|
160
169
|
[LINE_Y_FIELD]: item[Y_AXIS_FIELD]
|
|
161
170
|
}));
|
|
162
171
|
console.log('compareLineData:', compareLineData);
|
|
163
|
-
const lineMaxY = lineData.reduce((max, item)=>
|
|
164
|
-
|
|
172
|
+
const lineMaxY = lineData.reduce((max, item)=>{
|
|
173
|
+
if ('-' === item[LINE_Y_FIELD] || void 0 === item[LINE_Y_FIELD] || null === item[LINE_Y_FIELD] || '' === item[LINE_Y_FIELD]) return max;
|
|
174
|
+
return Math.max(max, item[LINE_Y_FIELD]);
|
|
175
|
+
}, 0);
|
|
176
|
+
const compareLineMaxY = compareLineData.reduce((max, item)=>{
|
|
177
|
+
if ('-' === item[LINE_Y_FIELD] || void 0 === item[LINE_Y_FIELD] || null === item[LINE_Y_FIELD] || '' === item[LINE_Y_FIELD]) return max;
|
|
178
|
+
return Math.max(max, item[LINE_Y_FIELD]);
|
|
179
|
+
}, 0);
|
|
165
180
|
const lineFinalMaxY = Math.max(lineMaxY, compareLineMaxY) || 1;
|
|
166
|
-
const finalLineMax = Math.max(lineFinalMaxY,
|
|
181
|
+
const finalLineMax = Math.max(lineFinalMaxY, maxAuxRight);
|
|
167
182
|
console.log('lineData:', lineData);
|
|
168
183
|
const line = view.line().data(lineData).encode("x", x).encode("y", LINE_Y_FIELD).encode('color', 'groupType').style({
|
|
169
184
|
lineWidth: 2,
|
|
@@ -210,7 +225,8 @@ function renderG2CombineChart(container, options) {
|
|
|
210
225
|
0
|
|
211
226
|
],
|
|
212
227
|
tickOpacity: 0,
|
|
213
|
-
labelFormatter: formatLineAxis
|
|
228
|
+
labelFormatter: formatLineAxis,
|
|
229
|
+
labelOpacity: 0.6
|
|
214
230
|
});
|
|
215
231
|
console.log('renderG2CombineChart: compare line data:', compareLineData);
|
|
216
232
|
const compareLine = view.line().data(compareLineData).encode('x', x).encode('y', LINE_Y_FIELD).encode('color', 'groupType').style({
|
|
@@ -265,96 +281,102 @@ function renderG2CombineChart(container, options) {
|
|
|
265
281
|
} : false
|
|
266
282
|
].filter(Boolean)
|
|
267
283
|
});
|
|
268
|
-
if (tooltipRender)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
284
|
+
if (tooltipRender) {
|
|
285
|
+
const intervalSort = (item)=>{
|
|
286
|
+
if (item.isChange) return 2;
|
|
287
|
+
if (item.name.includes('_compare')) return 1;
|
|
288
|
+
return 0;
|
|
289
|
+
};
|
|
290
|
+
view.interaction('tooltip', {
|
|
291
|
+
shared: true,
|
|
292
|
+
crosshairsY: true,
|
|
293
|
+
marker: false,
|
|
294
|
+
render: (event, payload)=>{
|
|
295
|
+
const { title, items } = payload;
|
|
296
|
+
let safeTitle = title.replace(/,.*$/, '');
|
|
297
|
+
const baseItems = items.filter((item)=>!item.isCombine);
|
|
298
|
+
const safeItems = baseItems.map((item)=>{
|
|
299
|
+
if (item.x !== safeTitle) return {
|
|
300
|
+
...item,
|
|
301
|
+
value: '-'
|
|
302
|
+
};
|
|
303
|
+
return item;
|
|
304
|
+
}).sort(intervalSort);
|
|
305
|
+
const combineItems = items.filter((item)=>item.isCombine);
|
|
306
|
+
const safeCombineItems = combineItems.map((item)=>{
|
|
307
|
+
if (item.x !== safeTitle) return {
|
|
308
|
+
...item,
|
|
309
|
+
value: '-'
|
|
310
|
+
};
|
|
311
|
+
return item;
|
|
312
|
+
});
|
|
313
|
+
const indicatorOrder = new Map(indicators.map((id, i)=>[
|
|
314
|
+
id,
|
|
315
|
+
i
|
|
316
|
+
]));
|
|
317
|
+
const sortedCombineItems = [
|
|
318
|
+
...safeCombineItems
|
|
319
|
+
].sort((a, b)=>{
|
|
320
|
+
const orderA = indicatorOrder.get(a.indicatorId) ?? 1 / 0;
|
|
321
|
+
const orderB = indicatorOrder.get(b.indicatorId) ?? 1 / 0;
|
|
322
|
+
if (orderA !== orderB) return orderA - orderB;
|
|
323
|
+
const typeRank = (item)=>{
|
|
324
|
+
if (item.isChange) return 2;
|
|
325
|
+
if ('compareline' === item.tipType) return 1;
|
|
326
|
+
return 0;
|
|
327
|
+
};
|
|
328
|
+
return typeRank(a) - typeRank(b);
|
|
329
|
+
});
|
|
330
|
+
const content = tooltipRender(safeTitle, [
|
|
331
|
+
...safeItems,
|
|
332
|
+
...sortedCombineItems
|
|
333
|
+
]) ?? null;
|
|
334
|
+
if (content) {
|
|
335
|
+
const domEvent = event?.event ?? event;
|
|
336
|
+
const clientX = domEvent?.clientX ?? domEvent?.x ?? 0;
|
|
337
|
+
const clientY = domEvent?.clientY ?? domEvent?.y ?? 0;
|
|
338
|
+
const rect = container.getBoundingClientRect();
|
|
339
|
+
const offsetX = 12;
|
|
340
|
+
const offsetY = 12;
|
|
341
|
+
const applyClamp = ()=>{
|
|
342
|
+
let el = content;
|
|
343
|
+
while(el && el.parentElement){
|
|
344
|
+
const p = el.parentElement;
|
|
345
|
+
if (p.classList?.contains('g2-tooltip')) {
|
|
346
|
+
el = p;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
325
349
|
el = p;
|
|
326
|
-
break;
|
|
327
350
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
const wrapper = el && el.classList?.contains('g2-tooltip') ? el : null;
|
|
352
|
+
if (!wrapper) return;
|
|
353
|
+
const wRect = wrapper.getBoundingClientRect();
|
|
354
|
+
const tooltipW = wRect.width || 260;
|
|
355
|
+
const tooltipH = wRect.height || 300;
|
|
356
|
+
const minLeft = rect.left;
|
|
357
|
+
const maxLeft = rect.right - tooltipW;
|
|
358
|
+
const minTop = rect.top;
|
|
359
|
+
const maxTop = rect.bottom - tooltipH;
|
|
360
|
+
const desiredLeft = clientX + offsetX;
|
|
361
|
+
const desiredTop = clientY + offsetY;
|
|
362
|
+
const left = Math.min(Math.max(desiredLeft, minLeft), Math.max(maxLeft, minLeft));
|
|
363
|
+
const top = Math.min(Math.max(desiredTop, minTop), Math.max(maxTop, minTop));
|
|
364
|
+
wrapper.style.position = 'fixed';
|
|
365
|
+
wrapper.style.left = `${left}px`;
|
|
366
|
+
wrapper.style.top = `${top}px`;
|
|
367
|
+
wrapper.style.transform = 'translate(0px, 0px)';
|
|
368
|
+
wrapper.style.pointerEvents = 'none';
|
|
369
|
+
wrapper.style.zIndex = '9999';
|
|
370
|
+
};
|
|
371
|
+
try {
|
|
372
|
+
applyClamp();
|
|
373
|
+
requestAnimationFrame(applyClamp);
|
|
374
|
+
} catch {}
|
|
375
|
+
}
|
|
376
|
+
return content;
|
|
354
377
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
});
|
|
378
|
+
});
|
|
379
|
+
}
|
|
358
380
|
view.legend(false);
|
|
359
381
|
view.interaction('poptip', {
|
|
360
382
|
offsetY: -20,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publishfx/publish-chart",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "A React chart component library for the Publish platform, including BarChart, LineChart, BarLineChart and other visualization components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|