Skip to content

Commit d013a7f

Browse files
committed
Fix - VueUiFlow - Fix height overlow with very large datasets
1 parent 1431d0a commit d013a7f

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
"vitest": "^3.1.1",
111111
"vue": "^3.5.14"
112112
}
113-
}
113+
}

src/components/vue-ui-flow.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,34 @@ function computeTotalHeight(nodeCoordinates) {
412412
}
413413
414414
const drawingArea = computed(() => {
415-
const { left, right, top, bottom } = FINAL_CONFIG.value.style.chart.padding;
416-
const maxNodeX = Math.max(...mutableDataset.value.nodes.map(n => n.x));
417-
const width = Math.ceil(maxNodeX + nodeWidth.value + right);
418-
const maxNodeY = Math.max(...mutableDataset.value.nodes.map(n => n.absoluteY + n.height));
419-
const height = Math.ceil(maxNodeY + bottom);
420-
return { width, height, left, top, right, bottom };
415+
const pad = FINAL_CONFIG.value.style.chart.padding;
416+
const padTop = pad.top;
417+
const padBottom = pad.bottom;
418+
const padLeft = pad.left;
419+
const padRight = pad.right;
420+
421+
const maxX = mutableDataset.value.nodes.reduce(
422+
(mx, n) => Math.max(mx, n.x),
423+
0
424+
);
425+
const width = padLeft + maxX + nodeWidth.value + padRight;
426+
427+
const maxNodeBottom = mutableDataset.value.nodes.reduce((mb, n) => {
428+
const nodeTop = n.y + padTop;
429+
const nodeBot = nodeTop + n.height;
430+
return Math.max(mb, nodeBot);
431+
}, 0);
432+
433+
const height = maxNodeBottom + padBottom;
434+
435+
return {
436+
width,
437+
height,
438+
left: padLeft,
439+
top: padTop,
440+
right: padRight,
441+
bottom: padBottom
442+
};
421443
});
422444
423445
function findConnectedNodes(startNode) {

0 commit comments

Comments
 (0)