fix: 拓扑显示居中响应改变宽高
This commit is contained in:
@@ -138,6 +138,8 @@ function handleRanderGraph(
|
|||||||
height: clientHeight - 36,
|
height: clientHeight - 36,
|
||||||
fitCenter: true,
|
fitCenter: true,
|
||||||
fitView: true,
|
fitView: true,
|
||||||
|
fitViewPadding: [40],
|
||||||
|
autoPaint: true,
|
||||||
modes: {
|
modes: {
|
||||||
default: [
|
default: [
|
||||||
'drag-combo',
|
'drag-combo',
|
||||||
@@ -166,6 +168,20 @@ function handleRanderGraph(
|
|||||||
|
|
||||||
graphG6.value = graph;
|
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;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { computed, reactive, ref } from 'vue';
|
|||||||
/**图状态 */
|
/**图状态 */
|
||||||
export const graphState = reactive<Record<string, any>>({
|
export const graphState = reactive<Record<string, any>>({
|
||||||
/**当前图组名 */
|
/**当前图组名 */
|
||||||
group: '5GC System Architecture2',
|
group: '5GC System Architecture3',
|
||||||
/**图数据 */
|
/**图数据 */
|
||||||
data: {
|
data: {
|
||||||
combos: [],
|
combos: [],
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const graphG6Dom = ref<HTMLElement | undefined>(undefined);
|
|||||||
/**图状态 */
|
/**图状态 */
|
||||||
const graphState = reactive<Record<string, any>>({
|
const graphState = reactive<Record<string, any>>({
|
||||||
/**当前图组名 */
|
/**当前图组名 */
|
||||||
group: '5GC System Architecture2',
|
group: '5GC System Architecture3',
|
||||||
/**图数据 */
|
/**图数据 */
|
||||||
data: {
|
data: {
|
||||||
combos: [],
|
combos: [],
|
||||||
@@ -182,6 +182,8 @@ function handleRanderGraph(
|
|||||||
height: clientHeight,
|
height: clientHeight,
|
||||||
fitCenter: true,
|
fitCenter: true,
|
||||||
fitView: true,
|
fitView: true,
|
||||||
|
fitViewPadding: [40],
|
||||||
|
autoPaint: true,
|
||||||
modes: {
|
modes: {
|
||||||
default: [
|
default: [
|
||||||
'drag-combo',
|
'drag-combo',
|
||||||
|
|||||||
Reference in New Issue
Block a user