@@ -412,12 +412,34 @@ function computeTotalHeight(nodeCoordinates) {
412412}
413413
414414const 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
423445function findConnectedNodes (startNode ) {
0 commit comments