fix: 拓扑显示居中响应改变宽高

This commit is contained in:
TsMask
2024-01-25 17:40:45 +08:00
parent 31651f8786
commit 47c07e7a3c
3 changed files with 20 additions and 2 deletions

View File

@@ -138,6 +138,8 @@ function handleRanderGraph(
height: clientHeight - 36,
fitCenter: true,
fitView: true,
fitViewPadding: [40],
autoPaint: true,
modes: {
default: [
'drag-combo',
@@ -166,6 +168,20 @@ function handleRanderGraph(
graphG6.value = graph;
// 创建 ResizeObserver 实例
var observer = new ResizeObserver(function (entries) {
// 当元素大小发生变化时触发回调函数
entries.forEach(function (entry) {
graphG6.value.changeSize(
entry.contentRect.width,
entry.contentRect.height - 30
);
graphG6.value.fitCenter();
});
});
// 监听元素大小变化
observer.observe(container);
return graph;
}