From f0189ac63361d68678cdfd400d6502bed3cf002e Mon Sep 17 00:00:00 2001 From: hanyuxia Date: Fri, 21 Jun 2024 15:10:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E4=BD=93=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E5=9B=BE=E4=BC=98=E5=8C=96:1.=E5=B7=A6=E4=B8=8A=E8=A7=92?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E5=8F=8A=E9=87=8D=E7=BD=AE=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/entityExplorer/EntityGraph.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/views/entityExplorer/EntityGraph.vue b/src/views/entityExplorer/EntityGraph.vue index 15852ba2..b559ee3a 100644 --- a/src/views/entityExplorer/EntityGraph.vue +++ b/src/views/entityExplorer/EntityGraph.vue @@ -89,7 +89,9 @@ export default { const initialData = await this.generateInitialData() this.initialData = _.cloneDeep(initialData) // 初始化数据 let hoverNode = null + let canvasHeight = document.body.clientHeight - 100 this.graph = ForceGraph()(document.getElementById('entityGraph')) + .height(canvasHeight) .graphData(initialData) .nodeCanvasObject((node, ctx) => { /* @@ -310,7 +312,7 @@ export default { node.name = builtTooltip(node) } }) - .centerAt(0, 30)// 设置中心节点位置 + .centerAt(0, 0)// 设置中心节点位置 .zoom(0.9999) .onNodeClick(async (node, e) => { this.isClicking = true @@ -691,8 +693,7 @@ export default { this.onCloseBlock() } } else if (code === 'autoZoom') { - this.graph.zoom(2) - this.graph.centerAt(0, 30) + this.graph.zoomToFit(100,100) } else if (code === 'zoomOut') { this.graph.zoom(this.graph.zoom() + 0.2) } else if (code === 'zoomIn') { @@ -705,7 +706,7 @@ export default { justUndo: false, justRedo: false } - this.graph.graphData(_.cloneDeep(this.initialData)).centerAt(0, 30) + this.graph.graphData(_.cloneDeep(this.initialData)).centerAt(0, 0).zoom(0.9999) } },