Skip to content

Commit

Permalink
fix: destroyLayout error, closes: #3727; fix: drag combo with stack p… (
Browse files Browse the repository at this point in the history
#3730)

* fix: destroyLayout error, closes: #3727; fix: drag combo with stack problem, closes: #3699; fix: updateLayout does not take effect if update layout with same type as graph instance configuration,  closes: #3706; fix: legendStateStyles typo, closes: #3705; perf: minimap cursor move;

* fix: zoom-canvas take the maximum and minimum values (#3711)

Co-authored-by: daichaofan <[email protected]>

* fix: 修复G6内置 shortcuts-call behavior 类型错误 (#3669)

Co-authored-by: 孙权 <[email protected]>

* docs: 修复graph.addItem,[graph.removeItem和graph.changeData超链接错误 (#3666)

Co-authored-by: fujunkui <[email protected]>

* feat: animate fitCenter and fitView (#3637)

* feat: animate fitCenter

* feat: animate fitView

* feat: enable edge selection in `click-select` (#3601)

* feat: enable edge selection in `click-select`

* fix: `click-select` click on canvas to deselect edges

* feat: add addItems function (#3578)

* feat: add addItems function

* Add tests

* More efficient combo sorting

* Remove comments

* Improve jsdoc

* Fix interface

* docs: update README

* chore: upgrade version nums

Co-authored-by: daichaofan <[email protected]>
Co-authored-by: daichaofan <[email protected]>
Co-authored-by: ruoruoji <[email protected]>
Co-authored-by: 孙权 <[email protected]>
Co-authored-by: fu1996 <[email protected]>
Co-authored-by: fujunkui <[email protected]>
Co-authored-by: Fabio Tacchelli <[email protected]>
Co-authored-by: AyajiLin <[email protected]>
  • Loading branch information
9 people authored Jun 17, 2022
1 parent 9596802 commit 90f1264
Show file tree
Hide file tree
Showing 38 changed files with 679 additions and 240 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# ChangeLog

#### 4.6.6

- fix: destroyLayout error, closes: #3727;
- fix: drag combo with stack problem, closes: #3699;
- fix: updateLayout does not take effect if update layout with same type as graph instance configuration, closes: #3706;
- fix: legendStateStyles typo, closes: #3705;
- perf: zoom-canvas take the maximum and minimum values instead of return directly;
- perf: minimap cursor move;
- feat: fitView and fitCenter with animation;
- feat: addItems to add multiple items into graph in the same time;
- feat: enable edge selection in click-select;

#### 4.6.4

- chore: improve the types of graph events;
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.9.5"
"typescript": "^4.6.3"
},
"devDependencies": {
"@types/react": "^16.9.35",
Expand All @@ -88,6 +88,7 @@
"monaco-editor": "0.29.1",
"monaco-editor-webpack-plugin": "5.0.0",
"react-monaco-editor": "^0.40.0",
"normalize-url": "^4.1.0"
"normalize-url": "^4.1.0",
"sharp": "^0.30.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-core",
"version": "0.6.4",
"version": "0.6.6",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -93,7 +93,7 @@
"rimraf": "^3.0.0",
"ts-jest": "^24.1.0",
"ts-loader": "^7.0.3",
"typescript": "^3.9.5",
"typescript": "^4.6.3",
"stats-js": "^1.0.1"
}
}
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.6.4',
version: '0.6.6',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/graph/controller/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class ItemController {
if (model.collapsed) {
setTimeout(() => {
if (!item.destroyed) {
graph.collapseCombo(item as ICombo);
graph.collapseCombo(item as ICombo, false);
graph.updateCombo(item as ICombo);
}
}, 0);
Expand Down Expand Up @@ -429,17 +429,17 @@ export default class ItemController {
/**
* 收起 combo,隐藏相关元素
*/
public collapseCombo(combo: ICombo | string) {
public collapseCombo(combo: ICombo | string, stack: boolean = true) {
const graph = this.graph;
if (isString(combo)) {
combo = graph.findById(combo) as ICombo;
}
const children = (combo as ICombo).getChildren();
children.nodes.forEach((node) => {
graph.hideItem(node);
graph.hideItem(node, stack);
});
children.combos.forEach((c) => {
graph.hideItem(c);
graph.hideItem(c, stack);
});
}

Expand Down Expand Up @@ -478,20 +478,20 @@ export default class ItemController {
* 展开 combo,相关元素出现
* 若子 combo 原先是收起状态,则保持它的收起状态
*/
public expandCombo(combo: ICombo | string) {
public expandCombo(combo: ICombo | string, stack: boolean = true) {
const graph = this.graph;
if (isString(combo)) {
combo = graph.findById(combo) as ICombo;
}
const children = (combo as ICombo).getChildren();
children.nodes.forEach((node) => {
graph.showItem(node);
graph.showItem(node, stack);
});
children.combos.forEach((c) => {
if (c.getModel().collapsed) {
c.show();
} else {
graph.showItem(c);
graph.showItem(c, stack);
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/graph/controller/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default abstract class LayoutController {

// 绘制
public refreshLayout() {
const { graph, layoutType, data } = this;
const { graph, layoutType } = this;
if (!graph) return;
if (graph.get('animate')) {
graph.positionsAnimate(layoutType === 'comboCombined');
Expand All @@ -81,6 +81,7 @@ export default abstract class LayoutController {
// 更换布局
public changeLayout(cfg) {
this.layoutCfg = cfg;
this.layoutType = cfg.type || this.layoutType;

this.destoryLayoutMethods();
this.layout();
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/graph/controller/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AbstractCanvas } from '@antv/g-base';
import { Point, IGroup } from '@antv/g-base';
import { isNumber, isString } from '@antv/util';
import { modifyCSS } from '@antv/dom-util';
import { Item, Matrix, Padding, GraphAnimateConfig, IEdge , FitViewRules} from '../../types';
import { Item, Matrix, Padding, GraphAnimateConfig, IEdge, FitViewRules } from '../../types';
import { formatPadding } from '../../util/base';
import { applyMatrix, invertMatrix } from '../../util/math';
import { IAbstractGraph } from '../../interface/graph';
Expand All @@ -29,7 +29,7 @@ export default class ViewController {
};
}

public fitCenter() {
public fitCenter(animate?: boolean, animateCfg?: GraphAnimateConfig) {
const { graph } = this;
const group: IGroup = graph.get('group');
group.resetMatrix();
Expand All @@ -41,11 +41,11 @@ export default class ViewController {
y: bbox.y + bbox.height / 2,
};

graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y);
graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y, animate, animateCfg);
}

// fit view graph
public fitView() {
public fitView(animate?: boolean, animateCfg?: GraphAnimateConfig) {
const { graph } = this;
const padding = this.getFormatPadding();
const width: number = graph.get('width');
Expand All @@ -62,20 +62,20 @@ export default class ViewController {
y: bbox.y + bbox.height / 2,
};

graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y);
graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y, animate, animateCfg);
const w = (width - padding[1] - padding[3]) / bbox.width;
const h = (height - padding[0] - padding[2]) / bbox.height;
let ratio = w;
if (w > h) {
ratio = h;
}
if(!graph.zoom(ratio, viewCenter)) {
if (!graph.zoom(ratio, viewCenter)) {
console.warn('zoom failed, ratio out of range, ratio: %f', ratio);
}
}

// fit view graph by rule
public fitViewByRules(rules: FitViewRules) {
public fitViewByRules(rules: FitViewRules, animate?: boolean, animateCfg?: GraphAnimateConfig) {
const {
onlyOutOfViewPort = false,
direction = 'both',
Expand All @@ -97,7 +97,7 @@ export default class ViewController {
y: bbox.y + bbox.height / 2,
};

graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y);
graph.translate(viewCenter.x - groupCenter.x, viewCenter.y - groupCenter.y, animate, animateCfg);
const wRatio = (width - padding[1] - padding[3]) / bbox.width;
const hRatio = (height - padding[0] - padding[2]) / bbox.height;
let ratio;
Expand All @@ -113,7 +113,7 @@ export default class ViewController {
if (onlyOutOfViewPort) {
ratio = ratio < 1 ? ratio : 1;
}

const initZoomRatio = graph.getZoom();
let endZoom = initZoomRatio * ratio;
const minZoom = graph.get('minZoom');
Expand All @@ -122,7 +122,7 @@ export default class ViewController {
endZoom = minZoom;
console.warn('fitview failed, ratio out of range, ratio: %f', ratio, 'graph minzoom has been used instead');
}
graph.zoomTo(endZoom, viewCenter);
graph.zoomTo(endZoom, viewCenter, animate, animateCfg);
}

public getFormatPadding(): number[] {
Expand Down
Loading

0 comments on commit 90f1264

Please sign in to comment.