From 8eb2000b988ba985ef2033ba11c1535a1a1d29e6 Mon Sep 17 00:00:00 2001 From: nghtlinh Date: Fri, 4 Apr 2025 15:44:09 -0400 Subject: [PATCH] Adjusted label calculation for x and y values --- packages/mermaid/src/diagrams/gantt/ganttRenderer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/ganttRenderer.js b/packages/mermaid/src/diagrams/gantt/ganttRenderer.js index e275f6f93..33b2a8020 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttRenderer.js +++ b/packages/mermaid/src/diagrams/gantt/ganttRenderer.js @@ -406,6 +406,9 @@ export const draw = function (text, id, version, diagObj) { if (d.milestone) { endX = startX + theBarHeight; } + if (d.vert) { + return startX + theSidePad + (endX - startX) / 2 - this.getBBox().width / 2; + } const textWidth = this.getBBox().width; @@ -423,9 +426,7 @@ export const draw = function (text, id, version, diagObj) { .attr('y', function (d, i) { // Ignore the incoming i value and use our order instead if (d.vert) { - return ( - conf.barHeight * numOccurrences.at(0).at(1) * 1.3 + (conf.fontSize / 2 - 2) + theTopPad - ); + return conf.gridLineStartPadding + taskArray.length * (conf.barHeight + conf.barGap) + 50; } i = d.order; return i * theGap + conf.barHeight / 2 + (conf.fontSize / 2 - 2) + theTopPad;