Skip to content

Commit

Permalink
perf: add updateShape function for donut node, closes: #4091; chore: … (
Browse files Browse the repository at this point in the history
#4178)

* perf: add updateShape function for donut node, closes: #4091; chore: refactor the implementation of donut node;

* feat: legend supports diamond, ellipse, triangle, star shape, closes: #3876;

* feat: add redo undo for TreeGraph, closes: #3664, #2414;

* chore: update version nums

* chore: refine
  • Loading branch information
Yanyan-Wang authored Jan 3, 2023
1 parent 759769b commit 27cd01d
Show file tree
Hide file tree
Showing 21 changed files with 487 additions and 178 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ChangeLog

### 4.8.2

- perf: add updateShape function for donut node, closes: #4091;
- chore: refactor the implementation of donut node;
- feat: legend supports diamond, ellipse, triangle, star shape, closes: #3876;
- feat: add redo undo for TreeGraph, closes: #3664, #2414;

### 4.8.1

- perf: use simple router for polyline when there is no obstacles, the performance is improved, closes: #2658;
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.8.1",
"version": "0.8.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.8.1',
version: '0.8.2',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,10 +1553,6 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs
}
}
}

if (this.get('enabledStack')) {
this.pushStack('render');
}
}

/**
Expand Down Expand Up @@ -3069,6 +3065,11 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs
if (this.get('enabledStack')) {
this.undoStack.clear();
this.redoStack.clear();

this.emit('stackchange', {
undoStack: this.undoStack,
redoStack: this.redoStack,
});
}
}

Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/util/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,28 @@ export function paddedHull(polyPoints: vec2[], padding: number) {
return { x: point[0], y: point[1] };
});
}

/**
* get a path of a star with outer radius and inner radius
* @param outerR
* @param innerR
* @returns
*/
export const getStarPath = (outerR: number, innerR: number) => {
const path = [];
for (let i = 0; i < 5; i++) {
const x1 = Math.cos(((18 + 72 * i) / 180) * Math.PI) * outerR;
const y1 = Math.sin(((18 + 72 * i) / 180) * Math.PI) * outerR;
const x2 = Math.cos(((54 + 72 * i) / 180) * Math.PI) * innerR;
const y2 = Math.sin(((54 + 72 * i) / 180) * Math.PI) * innerR;
if (i === 0) {
path.push(['M', x1, -y1]);
} else {
path.push(['L', x1, -y1]);
}
path.push(['L', x2, -y2]);
}

path.push(['Z']);
return path;
}
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.8.1",
"version": "0.8.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.8.1",
"@antv/g6-core": "0.8.2",
"@antv/util": "~2.0.5"
},
"devDependencies": {
Expand Down
12 changes: 0 additions & 12 deletions packages/element/src/nodes/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,6 @@ registerNode(
update(cfg: NodeConfig, item: Item, updateType?: UpdateType) {
const group = item.getContainer();
const size = (this as ShapeOptions).getSize!(cfg);
// 下面这些属性需要覆盖默认样式与目前样式,但若在 cfg 中有指定则应该被 cfg 的相应配置覆盖。
// const strokeStyle = {
// stroke: cfg.color,
// r: size[0] / 2,
// };
// // 与 getShapeStyle 不同在于,update 时需要获取到当前的 style 进行融合。即新传入的配置项中没有涉及的属性,保留当前的配置。
// const keyShape = item.get('keyShape');

// TODO: performance
// const style = deepMix({}, keyShape.attr(), strokeStyle, cfg.style);
// const style = deepMix({}, keyShape.attr(), cfg.style);
const style = { ...cfg.style };
if (cfg.style.stroke === undefined && cfg.color) {
style.stroke = cfg.color;
Expand All @@ -230,7 +219,6 @@ registerNode(
}

(this as any).updateShape(cfg, item, style, true, updateType);
// (this as any).updateShape(cfg, item, style, true, updateType);
(this as any).updateLinkPoints(cfg, group);
},
},
Expand Down
Loading

0 comments on commit 27cd01d

Please sign in to comment.