feat: 实体关系图优化:1.左上角自适应及重置工具
This commit is contained in:
@@ -89,7 +89,9 @@ export default {
|
|||||||
const initialData = await this.generateInitialData()
|
const initialData = await this.generateInitialData()
|
||||||
this.initialData = _.cloneDeep(initialData) // 初始化数据
|
this.initialData = _.cloneDeep(initialData) // 初始化数据
|
||||||
let hoverNode = null
|
let hoverNode = null
|
||||||
|
let canvasHeight = document.body.clientHeight - 100
|
||||||
this.graph = ForceGraph()(document.getElementById('entityGraph'))
|
this.graph = ForceGraph()(document.getElementById('entityGraph'))
|
||||||
|
.height(canvasHeight)
|
||||||
.graphData(initialData)
|
.graphData(initialData)
|
||||||
.nodeCanvasObject((node, ctx) => {
|
.nodeCanvasObject((node, ctx) => {
|
||||||
/*
|
/*
|
||||||
@@ -310,7 +312,7 @@ export default {
|
|||||||
node.name = builtTooltip(node)
|
node.name = builtTooltip(node)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.centerAt(0, 30)// 设置中心节点位置
|
.centerAt(0, 0)// 设置中心节点位置
|
||||||
.zoom(0.9999)
|
.zoom(0.9999)
|
||||||
.onNodeClick(async (node, e) => {
|
.onNodeClick(async (node, e) => {
|
||||||
this.isClicking = true
|
this.isClicking = true
|
||||||
@@ -691,8 +693,7 @@ export default {
|
|||||||
this.onCloseBlock()
|
this.onCloseBlock()
|
||||||
}
|
}
|
||||||
} else if (code === 'autoZoom') {
|
} else if (code === 'autoZoom') {
|
||||||
this.graph.zoom(2)
|
this.graph.zoomToFit(100,100)
|
||||||
this.graph.centerAt(0, 30)
|
|
||||||
} else if (code === 'zoomOut') {
|
} else if (code === 'zoomOut') {
|
||||||
this.graph.zoom(this.graph.zoom() + 0.2)
|
this.graph.zoom(this.graph.zoom() + 0.2)
|
||||||
} else if (code === 'zoomIn') {
|
} else if (code === 'zoomIn') {
|
||||||
@@ -705,7 +706,7 @@ export default {
|
|||||||
justUndo: false,
|
justUndo: false,
|
||||||
justRedo: false
|
justRedo: false
|
||||||
}
|
}
|
||||||
this.graph.graphData(_.cloneDeep(this.initialData)).centerAt(0, 30)
|
this.graph.graphData(_.cloneDeep(this.initialData)).centerAt(0, 0).zoom(0.9999)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user