Skip to content

Commit 981a62e

Browse files
knsvclaude
andcommitted
fix(gitGraph): correct BT orientation arc sweep flags in drawArrow()
Swap SVG arc sweep-flag values in the BT (bottom-to-top) orientation branches of drawArrow() so curves bend in the correct direction. Fixes both rerouting and non-rerouting code paths for merge and non-merge arrows. Also fixes an incorrect x-coordinate in the non-rerouting BT p1.x>p2.x non-merge case. Resolves #6593 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 66a65ad commit 981a62e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.changeset/fix-bt-arc-curves.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: correct BT orientation arc sweep flags in gitGraph drawArrow()
6+
7+
Swapped SVG arc sweep-flag values in the BT (bottom-to-top) orientation branches of `drawArrow()` so curves bend in the correct direction. Affects both rerouting and non-rerouting code paths for merge and non-merge arrows.
8+
9+
Resolves #6593

packages/mermaid/src/diagrams/git/gitGraphRenderer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,14 +657,14 @@ const drawArrow = (
657657
// Source commit is on branch position left of destination commit
658658
// so render arrow rightward with colour of destination branch
659659

660-
lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc2} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
660+
lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
661661
} else {
662662
// Source commit is on branch position right of destination commit
663663
// so render arrow leftward with colour of source branch
664664

665665
colorClassNum = branchPos.get(commitA.branch)?.index;
666666

667-
lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc2} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
667+
lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
668668
}
669669
} else {
670670
if (p1.y < p2.y) {
@@ -725,11 +725,11 @@ const drawArrow = (
725725
} else if (dir === 'BT') {
726726
if (p1.x < p2.x) {
727727
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
728-
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${
728+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x + offset} ${
729729
p2.y
730730
} L ${p2.x} ${p2.y}`;
731731
} else {
732-
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${
732+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${
733733
p1.y - offset
734734
} L ${p2.x} ${p2.y}`;
735735
}
@@ -741,11 +741,11 @@ const drawArrow = (
741741
offset = 20;
742742

743743
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
744-
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${
744+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x - offset} ${
745745
p2.y
746746
} L ${p2.x} ${p2.y}`;
747747
} else {
748-
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${
748+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc2} ${p2.x} ${
749749
p1.y - offset
750750
} L ${p2.x} ${p2.y}`;
751751
}

0 commit comments

Comments
 (0)