diff --git a/package.json b/package.json index 86409d5059..e8eb6d0e09 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,8 @@ "test": "jest", "test-live": "DEBUG_MODE=1 jest --watch ./tests/unit/layout/dagre-spec.ts", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx", - "watch": "father build -w" + "watch": "father build -w", + "cdn": "antv-bin upload -n @antv/g6" }, "husky": { "hooks": { diff --git a/src/graph/tree-graph.ts b/src/graph/tree-graph.ts index 6b1b19f214..5ee3a9835e 100644 --- a/src/graph/tree-graph.ts +++ b/src/graph/tree-graph.ts @@ -214,6 +214,20 @@ export default class TreeGraph extends Graph implements ITreeGraph { self.layout(this.get('fitView')); } } + /** + * 更改并应用树布局算法 + * @param {object} layout 布局算法 + */ + public updateLayout(layout) { + const self = this; + if (!layout) { + console.warn('layout cannot be null'); + return; + } + self.set('layout', layout); + self.set('layoutMethod', self.getLayout()); + self.layout(); + } /** * 根据目前的 data 刷新布局,更新到画布上。用于变更数据之后刷新视图。