Skip to content

Commit

Permalink
feat: Annotation plugin supports configuring behaviors for collapse a… (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
Yanyan-Wang authored Sep 7, 2022
1 parent 63f43ce commit 8a4f7a5
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 160 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ChangeLog

### 4.7.2

- 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;

#### 4.7.1

- feat: Annotation plugin;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-core",
"version": "0.7.1",
"version": "0.7.2",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const colorSet = {
};

export default {
version: '0.7.1',
version: '0.7.2',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,12 +1119,8 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs
this.set('comboTrees', comboTrees);

if (model.collapsed) {
setTimeout(() => {
if (item && !item.destroyed) {
this.collapseCombo(item as ICombo, false);
this.updateCombo(item as ICombo);
}
}, 0);
this.collapseCombo(item as ICombo, false);
this.updateCombo(item as ICombo);
}

} else if (type === 'node' && isString(model.comboId) && comboTrees) {
Expand Down
4 changes: 2 additions & 2 deletions packages/element/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-element",
"version": "0.7.1",
"version": "0.7.2",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -61,7 +61,7 @@
},
"dependencies": {
"@antv/g-base": "^0.5.1",
"@antv/g6-core": "0.7.1",
"@antv/g6-core": "0.7.2",
"@antv/util": "~2.0.5"
},
"devDependencies": {
Expand Down
30 changes: 21 additions & 9 deletions packages/element/src/edges/polyline-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,31 @@ export const getPolylinePoints = (
if (!sNode || !sNode.getType()) {
sBBox = getBBoxFromPoint(start);
} else if (sNode.getType() === 'combo') {
const sNodeKeyShape = sNode.getKeyShape();
sBBox = sNodeKeyShape.getCanvasBBox() || (getBBoxFromPoint(start) as PBBox);
sBBox.centerX = (sBBox.minX + sBBox.maxX) / 2;
sBBox.centerY = (sBBox.minY + sBBox.maxY) / 2;
const sKeyShapeBBox = sNode.getKeyShape().getBBox();
if (sKeyShapeBBox) {
const { x: sx, y: sy } = sNode.getModel();
sBBox = {
x: sx,
y: sy,
width: sKeyShapeBBox.width,
height: sKeyShapeBBox.height,
minX: sKeyShapeBBox.minX + sx,
maxX: sKeyShapeBBox.maxX + sx,
minY: sKeyShapeBBox.minY + sy,
maxY: sKeyShapeBBox.maxY + sy,
}
sBBox.centerX = (sBBox.minX + sBBox.maxX) / 2;
sBBox.centerY = (sBBox.minY + sBBox.maxY) / 2;
} else {
sBBox = getBBoxFromPoint(start) as PBBox
}
} else {
sBBox = sNode.getBBox();
sBBox = sNode && sNode.getBBox();
}

if (!tNode || !tNode.getType()) {
tBBox = getBBoxFromPoint(end);
}
else if (tNode.getType() === 'combo') {
} else if (tNode.getType() === 'combo') {
const tKeyShapeBBox = tNode.getKeyShape().getBBox();
if (tKeyShapeBBox) {
const { x: tx, y: ty } = tNode.getModel();
Expand All @@ -510,8 +523,7 @@ export const getPolylinePoints = (
} else {
tBBox = getBBoxFromPoint(end) as PBBox
}
}
else {
} else {
tBBox = tNode && tNode.getBBox();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/element/src/edges/polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ registerEdge(
const polylinePoints = simple
? getPolylinePoints(points[points.length - 1], points[0], target, source, offset)
: pathFinder(points[0], points[points.length - 1], source, target, routeCfg);

if (!polylinePoints || !polylinePoints.length) return 'M0 0, L0 0';

if (radius) {
Expand Down
4 changes: 2 additions & 2 deletions packages/g6/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6",
"version": "4.7.1",
"version": "4.7.2",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -66,7 +66,7 @@
]
},
"dependencies": {
"@antv/g6-pc": "0.7.1"
"@antv/g6-pc": "0.7.2"
},
"devDependencies": {
"@babel/core": "^7.7.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/g6/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import G6 from '@antv/g6-pc';

G6.version = '4.7.1';
G6.version = '4.7.2';

export * from '@antv/g6-pc';
export default G6;
export const version = '4.7.1';
export const version = '4.7.2';
8 changes: 4 additions & 4 deletions packages/pc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-pc",
"version": "0.7.1",
"version": "0.7.2",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -75,9 +75,9 @@
"@antv/g-canvas": "^0.5.2",
"@antv/g-math": "^0.1.1",
"@antv/g-svg": "^0.5.1",
"@antv/g6-core": "0.7.1",
"@antv/g6-element": "0.7.1",
"@antv/g6-plugin": "0.7.1",
"@antv/g6-core": "0.7.2",
"@antv/g6-element": "0.7.2",
"@antv/g6-plugin": "0.7.2",
"@antv/hierarchy": "^0.6.7",
"@antv/layout": "^0.3.0",
"@antv/matrix-util": "^3.1.0-beta.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/pc/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const textColor = 'rgb(0, 0, 0)';
const colorSet = getColorsWithSubjectColor(subjectColor, backColor);

export default {
version: '0.7.1',
version: '0.7.2',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
4 changes: 2 additions & 2 deletions packages/pc/src/graph/controller/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ export default class LayoutController extends AbstractLayout {
const isForce = layoutType === 'force' || layoutType === 'g6force' || layoutType === 'gForce' || layoutType === 'force2';
if (isForce) {
const { onTick, animate } = layoutCfg;
const d3ForceAnimate = animate === undefined && layoutType === 'force'
const isDefaultAnimateLayout = animate === undefined && (layoutType === 'force' || layoutType === 'force2');
const tick = () => {
if (onTick) {
onTick();
}
if (animate || d3ForceAnimate) graph.refreshPositions();
if (animate || isDefaultAnimateLayout) graph.refreshPositions();
};
layoutCfg.tick = tick;
} else if (layoutType === 'comboForce' || layoutType === 'comboCombined') {
Expand Down
5 changes: 2 additions & 3 deletions packages/pc/tests/unit/layout/circular-web-worker-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ describe('circular layout(web worker)', () => {
height: 500,
defaultNode: { size: 10 },
});
graph.data(data);
graph.render();

graph.on('afterlayout', () => {
const width = graph.get('width');
const height = graph.get('height');
Expand All @@ -35,6 +32,8 @@ describe('circular layout(web worker)', () => {
graph.destroy();
done();
});
graph.data(data);
graph.render();
});

it('circular(web worker) counterclockwise, and fixed radius, start angle, end angle', done => {
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-plugin",
"version": "0.7.1",
"version": "0.7.2",
"description": "G6 Plugin",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -22,8 +22,8 @@
"@antv/g-base": "^0.5.1",
"@antv/g-canvas": "^0.5.2",
"@antv/g-svg": "^0.5.2",
"@antv/g6-core": "0.7.1",
"@antv/g6-element": "0.7.1",
"@antv/g6-core": "0.7.2",
"@antv/g6-element": "0.7.2",
"@antv/matrix-util": "^3.1.0-beta.3",
"@antv/scale": "^0.3.4",
"@antv/util": "^2.0.9",
Expand Down
Loading

0 comments on commit 8a4f7a5

Please sign in to comment.