Skip to content

Commit 8a4f7a5

Browse files
authored
feat: Annotation plugin supports configuring behaviors for collapse a… (#3921)
* feat: Annotation plugin supports configuring behaviors for collapse and close icon; feat: Annotation plugin supports canvas annotation; fix: gForce layout has animation by default; * fix: createCombo creates vedges asynchronously, closes: #3912; fix: strange polyline path edge related to combo, closes: #3913; * chore: refine * chore: refine
1 parent 63f43ce commit 8a4f7a5

File tree

17 files changed

+327
-160
lines changed

17 files changed

+327
-160
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# ChangeLog
22

3+
### 4.7.2
4+
5+
- feat: Annotation plugin supports configuring behaviors for collapse and close icon;
6+
- feat: Annotation plugin supports canvas annotation;
7+
- fix: gForce layout has animation by default;
8+
- fix: createCombo creates vedges asynchronously, closes: #3912;
9+
- fix: strange polyline path edge related to combo, closes: #3913;
10+
311
#### 4.7.1
412

513
- feat: Annotation plugin;

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-core",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",

packages/core/src/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const colorSet = {
6464
};
6565

6666
export default {
67-
version: '0.7.1',
67+
version: '0.7.2',
6868
rootContainerClassName: 'root-container',
6969
nodeContainerClassName: 'node-container',
7070
edgeContainerClassName: 'edge-container',

packages/core/src/graph/graph.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1119,12 +1119,8 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs
11191119
this.set('comboTrees', comboTrees);
11201120

11211121
if (model.collapsed) {
1122-
setTimeout(() => {
1123-
if (item && !item.destroyed) {
1124-
this.collapseCombo(item as ICombo, false);
1125-
this.updateCombo(item as ICombo);
1126-
}
1127-
}, 0);
1122+
this.collapseCombo(item as ICombo, false);
1123+
this.updateCombo(item as ICombo);
11281124
}
11291125

11301126
} else if (type === 'node' && isString(model.comboId) && comboTrees) {

packages/element/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-element",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -61,7 +61,7 @@
6161
},
6262
"dependencies": {
6363
"@antv/g-base": "^0.5.1",
64-
"@antv/g6-core": "0.7.1",
64+
"@antv/g6-core": "0.7.2",
6565
"@antv/util": "~2.0.5"
6666
},
6767
"devDependencies": {

packages/element/src/edges/polyline-util.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,31 @@ export const getPolylinePoints = (
480480
if (!sNode || !sNode.getType()) {
481481
sBBox = getBBoxFromPoint(start);
482482
} else if (sNode.getType() === 'combo') {
483-
const sNodeKeyShape = sNode.getKeyShape();
484-
sBBox = sNodeKeyShape.getCanvasBBox() || (getBBoxFromPoint(start) as PBBox);
485-
sBBox.centerX = (sBBox.minX + sBBox.maxX) / 2;
486-
sBBox.centerY = (sBBox.minY + sBBox.maxY) / 2;
483+
const sKeyShapeBBox = sNode.getKeyShape().getBBox();
484+
if (sKeyShapeBBox) {
485+
const { x: sx, y: sy } = sNode.getModel();
486+
sBBox = {
487+
x: sx,
488+
y: sy,
489+
width: sKeyShapeBBox.width,
490+
height: sKeyShapeBBox.height,
491+
minX: sKeyShapeBBox.minX + sx,
492+
maxX: sKeyShapeBBox.maxX + sx,
493+
minY: sKeyShapeBBox.minY + sy,
494+
maxY: sKeyShapeBBox.maxY + sy,
495+
}
496+
sBBox.centerX = (sBBox.minX + sBBox.maxX) / 2;
497+
sBBox.centerY = (sBBox.minY + sBBox.maxY) / 2;
498+
} else {
499+
sBBox = getBBoxFromPoint(start) as PBBox
500+
}
487501
} else {
488-
sBBox = sNode.getBBox();
502+
sBBox = sNode && sNode.getBBox();
489503
}
490504

491505
if (!tNode || !tNode.getType()) {
492506
tBBox = getBBoxFromPoint(end);
493-
}
494-
else if (tNode.getType() === 'combo') {
507+
} else if (tNode.getType() === 'combo') {
495508
const tKeyShapeBBox = tNode.getKeyShape().getBBox();
496509
if (tKeyShapeBBox) {
497510
const { x: tx, y: ty } = tNode.getModel();
@@ -510,8 +523,7 @@ export const getPolylinePoints = (
510523
} else {
511524
tBBox = getBBoxFromPoint(end) as PBBox
512525
}
513-
}
514-
else {
526+
} else {
515527
tBBox = tNode && tNode.getBBox();
516528
}
517529

packages/element/src/edges/polyline.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ registerEdge(
194194
const polylinePoints = simple
195195
? getPolylinePoints(points[points.length - 1], points[0], target, source, offset)
196196
: pathFinder(points[0], points[points.length - 1], source, target, routeCfg);
197-
197+
198198
if (!polylinePoints || !polylinePoints.length) return 'M0 0, L0 0';
199199

200200
if (radius) {

packages/g6/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6",
3-
"version": "4.7.1",
3+
"version": "4.7.2",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -66,7 +66,7 @@
6666
]
6767
},
6868
"dependencies": {
69-
"@antv/g6-pc": "0.7.1"
69+
"@antv/g6-pc": "0.7.2"
7070
},
7171
"devDependencies": {
7272
"@babel/core": "^7.7.7",

packages/g6/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import G6 from '@antv/g6-pc';
22

3-
G6.version = '4.7.1';
3+
G6.version = '4.7.2';
44

55
export * from '@antv/g6-pc';
66
export default G6;
7-
export const version = '4.7.1';
7+
export const version = '4.7.2';

packages/pc/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-pc",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -75,9 +75,9 @@
7575
"@antv/g-canvas": "^0.5.2",
7676
"@antv/g-math": "^0.1.1",
7777
"@antv/g-svg": "^0.5.1",
78-
"@antv/g6-core": "0.7.1",
79-
"@antv/g6-element": "0.7.1",
80-
"@antv/g6-plugin": "0.7.1",
78+
"@antv/g6-core": "0.7.2",
79+
"@antv/g6-element": "0.7.2",
80+
"@antv/g6-plugin": "0.7.2",
8181
"@antv/hierarchy": "^0.6.7",
8282
"@antv/layout": "^0.3.0",
8383
"@antv/matrix-util": "^3.1.0-beta.3",

packages/pc/src/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const textColor = 'rgb(0, 0, 0)';
77
const colorSet = getColorsWithSubjectColor(subjectColor, backColor);
88

99
export default {
10-
version: '0.7.1',
10+
version: '0.7.2',
1111
rootContainerClassName: 'root-container',
1212
nodeContainerClassName: 'node-container',
1313
edgeContainerClassName: 'edge-container',

packages/pc/src/graph/controller/layout.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ export default class LayoutController extends AbstractLayout {
132132
const isForce = layoutType === 'force' || layoutType === 'g6force' || layoutType === 'gForce' || layoutType === 'force2';
133133
if (isForce) {
134134
const { onTick, animate } = layoutCfg;
135-
const d3ForceAnimate = animate === undefined && layoutType === 'force'
135+
const isDefaultAnimateLayout = animate === undefined && (layoutType === 'force' || layoutType === 'force2');
136136
const tick = () => {
137137
if (onTick) {
138138
onTick();
139139
}
140-
if (animate || d3ForceAnimate) graph.refreshPositions();
140+
if (animate || isDefaultAnimateLayout) graph.refreshPositions();
141141
};
142142
layoutCfg.tick = tick;
143143
} else if (layoutType === 'comboForce' || layoutType === 'comboCombined') {

packages/pc/tests/unit/layout/circular-web-worker-spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ describe('circular layout(web worker)', () => {
2121
height: 500,
2222
defaultNode: { size: 10 },
2323
});
24-
graph.data(data);
25-
graph.render();
26-
2724
graph.on('afterlayout', () => {
2825
const width = graph.get('width');
2926
const height = graph.get('height');
@@ -35,6 +32,8 @@ describe('circular layout(web worker)', () => {
3532
graph.destroy();
3633
done();
3734
});
35+
graph.data(data);
36+
graph.render();
3837
});
3938

4039
it('circular(web worker) counterclockwise, and fixed radius, start angle, end angle', done => {

packages/plugin/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-plugin",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "G6 Plugin",
55
"main": "lib/index.js",
66
"module": "es/index.js",
@@ -22,8 +22,8 @@
2222
"@antv/g-base": "^0.5.1",
2323
"@antv/g-canvas": "^0.5.2",
2424
"@antv/g-svg": "^0.5.2",
25-
"@antv/g6-core": "0.7.1",
26-
"@antv/g6-element": "0.7.1",
25+
"@antv/g6-core": "0.7.2",
26+
"@antv/g6-element": "0.7.2",
2727
"@antv/matrix-util": "^3.1.0-beta.3",
2828
"@antv/scale": "^0.3.4",
2929
"@antv/util": "^2.0.9",

0 commit comments

Comments
 (0)