@publishfx/publish-chart 2.1.38 → 2.1.41
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 +6 -0
- package/dist/components/composite/GroupLineCompare.js +46 -10
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
**2.1.41** feat(chart): 分组对比折线图自定义图例与tooltip交互优化 f-6719092744
|
|
2
|
+
- 2026-06-16T16:45:08+08:00 [feat(chart): 分组对比折线图自定义图例与tooltip交互优化 f-6719092744](http://lf.git.oa.mt/publish_platform/web/publish/commit/446f1dcea5fa50c1db96a395747bf26a5213a2f5)
|
|
3
|
+
|
|
4
|
+
**2.1.39** feat(chart): 分组对比折线图自定义图例与tooltip交互优化 f-6719092744
|
|
5
|
+
- 2026-06-16T16:45:08+08:00 [feat(chart): 分组对比折线图自定义图例与tooltip交互优化 f-6719092744](http://lf.git.oa.mt/publish_platform/web/publish/commit/446f1dcea5fa50c1db96a395747bf26a5213a2f5)
|
|
6
|
+
|
|
1
7
|
**2.1.38** feat(chart): 分组对比折线图自定义图例逻辑优化 f-6719092744
|
|
2
8
|
- 2026-06-16T14:36:13+08:00 [feat(chart): 分组对比折线图自定义图例逻辑优化 f-6719092744](http://lf.git.oa.mt/publish_platform/web/publish/commit/a03eaf696cb567384e0e888cb2cd1a86046ecae3)
|
|
3
9
|
- 2026-06-09T11:58:41+08:00 [feat(chart): 撤销组合图tooltip优化 f-6854368983](http://lf.git.oa.mt/publish_platform/web/publish/commit/1b7e955aa4ff680ce2bad27c3709306d3f12c7d3)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import react, { memo, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import react, { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Axis, Chart, Legend, Line, Tooltip, View } from "bizcharts";
|
|
4
4
|
import styled_components from "styled-components";
|
|
5
5
|
import lib from "@antv/data-set/lib";
|
|
@@ -56,6 +56,8 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
56
56
|
const [colorMap, setColorMap] = useState({});
|
|
57
57
|
const [checkedLegendItems, setCheckedLegendItems] = useState(new Set());
|
|
58
58
|
const [legendItems, setLegendItems] = useState([]);
|
|
59
|
+
const prevLegendItemsRef = useRef([]);
|
|
60
|
+
const isFirstRenderRef = useRef(true);
|
|
59
61
|
const [padding, setPadding] = useState([
|
|
60
62
|
20,
|
|
61
63
|
10,
|
|
@@ -124,6 +126,17 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
124
126
|
maxY,
|
|
125
127
|
transformData
|
|
126
128
|
]);
|
|
129
|
+
useEffect(()=>{
|
|
130
|
+
if (transformData.length > 0) {
|
|
131
|
+
const groupTypeSet = new Set();
|
|
132
|
+
transformData.forEach((item)=>{
|
|
133
|
+
groupTypeSet.add(item.groupType);
|
|
134
|
+
});
|
|
135
|
+
setCheckedLegendItems(groupTypeSet);
|
|
136
|
+
}
|
|
137
|
+
}, [
|
|
138
|
+
isLegend
|
|
139
|
+
]);
|
|
127
140
|
useEffect(()=>{
|
|
128
141
|
const groupTypeSet = new Set();
|
|
129
142
|
transformData.forEach((item)=>{
|
|
@@ -155,7 +168,22 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
155
168
|
}));
|
|
156
169
|
setColorMap(colorMap);
|
|
157
170
|
setLegendItems(legendItems);
|
|
158
|
-
setCheckedLegendItems(
|
|
171
|
+
setCheckedLegendItems((prev)=>{
|
|
172
|
+
if (isFirstRenderRef.current) {
|
|
173
|
+
isFirstRenderRef.current = false;
|
|
174
|
+
return groupTypeSet;
|
|
175
|
+
}
|
|
176
|
+
const prevLegendNames = new Set(prevLegendItemsRef.current.map((item)=>item.name));
|
|
177
|
+
const next = new Set();
|
|
178
|
+
groupTypeSet.forEach((item)=>{
|
|
179
|
+
const baseItem = item.endsWith('_compare') ? item.replace('_compare', '') : item;
|
|
180
|
+
if (prevLegendNames.has(baseItem)) {
|
|
181
|
+
if (prev.has(baseItem)) next.add(item);
|
|
182
|
+
} else next.add(item);
|
|
183
|
+
});
|
|
184
|
+
return next;
|
|
185
|
+
});
|
|
186
|
+
prevLegendItemsRef.current = legendItems;
|
|
159
187
|
}, [
|
|
160
188
|
transformData
|
|
161
189
|
]);
|
|
@@ -220,6 +248,13 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
220
248
|
transformData,
|
|
221
249
|
x
|
|
222
250
|
]);
|
|
251
|
+
const finalLegendItems = useMemo(()=>legendItems.map((item)=>({
|
|
252
|
+
...item,
|
|
253
|
+
unchecked: !checkedLegendItems.has(item.name)
|
|
254
|
+
})), [
|
|
255
|
+
legendItems,
|
|
256
|
+
checkedLegendItems
|
|
257
|
+
]);
|
|
223
258
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
224
259
|
height: height || 300,
|
|
225
260
|
data: transformData,
|
|
@@ -302,17 +337,19 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
302
337
|
}),
|
|
303
338
|
/*#__PURE__*/ jsx(Tooltip, {
|
|
304
339
|
shared: true,
|
|
305
|
-
showCrosshairs:
|
|
340
|
+
showCrosshairs: checkedLegendItems.size > 0,
|
|
306
341
|
children: (title, items)=>{
|
|
307
|
-
|
|
342
|
+
if (0 === checkedLegendItems.size) return null;
|
|
343
|
+
const activeItems = items?.filter((item)=>checkedLegendItems.has(item.name)) || [];
|
|
344
|
+
const originItems = activeItems.filter((item)=>!item.name.includes('_compare'));
|
|
308
345
|
return /*#__PURE__*/ jsx("div", {
|
|
309
346
|
style: {
|
|
310
347
|
padding: '10px 0'
|
|
311
348
|
},
|
|
312
|
-
children:
|
|
349
|
+
children: originItems.length > 0 && /*#__PURE__*/ jsxs(StyledTooltip, {
|
|
313
350
|
children: [
|
|
314
|
-
originItems
|
|
315
|
-
const compareItem =
|
|
351
|
+
originItems.map((it, index)=>{
|
|
352
|
+
const compareItem = activeItems.find((item)=>item.name === `${it.name}_compare`) || {};
|
|
316
353
|
return /*#__PURE__*/ jsxs(react.Fragment, {
|
|
317
354
|
children: [
|
|
318
355
|
!index && /*#__PURE__*/ jsxs("div", {
|
|
@@ -400,7 +437,7 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
400
437
|
]
|
|
401
438
|
}, index))
|
|
402
439
|
]
|
|
403
|
-
})
|
|
440
|
+
})
|
|
404
441
|
});
|
|
405
442
|
}
|
|
406
443
|
}),
|
|
@@ -442,8 +479,7 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
442
479
|
custom: true,
|
|
443
480
|
position: "bottom-left",
|
|
444
481
|
name: legend,
|
|
445
|
-
items:
|
|
446
|
-
filter: (name)=>checkedLegendItems.has(name),
|
|
482
|
+
items: finalLegendItems,
|
|
447
483
|
onChange: (e)=>{
|
|
448
484
|
const { unchecked, name } = e.item;
|
|
449
485
|
setCheckedLegendItems((prev)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publishfx/publish-chart",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.41",
|
|
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": [
|
|
@@ -24,20 +24,10 @@
|
|
|
24
24
|
"CHANGELOG.md",
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "rslib build",
|
|
29
|
-
"dev": "rslib build --watch",
|
|
30
|
-
"lint": "eslint src --ext .ts,.tsx",
|
|
31
|
-
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
32
|
-
"test": "jest",
|
|
33
|
-
"test:watch": "jest --watch",
|
|
34
|
-
"test:coverage": "jest --coverage"
|
|
35
|
-
},
|
|
36
27
|
"devDependencies": {
|
|
37
28
|
"@antv/data-set": "^0.11.8",
|
|
38
29
|
"@antv/g-pattern": "^2.0.42",
|
|
39
30
|
"@antv/g2": "^5.3.0",
|
|
40
|
-
"@publishfx/publish-components": "workspace:^",
|
|
41
31
|
"@types/jest": "^29.5.12",
|
|
42
32
|
"@types/lodash": "^4.17.20",
|
|
43
33
|
"@types/react": "^18.3.18",
|
|
@@ -55,7 +45,8 @@
|
|
|
55
45
|
"react-dom": "^18.3.1",
|
|
56
46
|
"styled-components": "^5.3.11",
|
|
57
47
|
"ts-jest": "^29.1.2",
|
|
58
|
-
"typescript": "^5.9.3"
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"@publishfx/publish-components": "^2.1.8"
|
|
59
50
|
},
|
|
60
51
|
"peerDependencies": {
|
|
61
52
|
"@antv/data-set": "^0.11.8",
|
|
@@ -71,5 +62,14 @@
|
|
|
71
62
|
"publishConfig": {
|
|
72
63
|
"access": "public",
|
|
73
64
|
"registry": "https://registry.npmjs.org/"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "rslib build",
|
|
68
|
+
"dev": "rslib build --watch",
|
|
69
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
70
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
71
|
+
"test": "jest",
|
|
72
|
+
"test:watch": "jest --watch",
|
|
73
|
+
"test:coverage": "jest --coverage"
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|