mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 12:59:46 +02:00
fix LR layout - node position and arrow direction.
This commit is contained in:
7
dist/www/javascripts/lib/mermaid.js
vendored
7
dist/www/javascripts/lib/mermaid.js
vendored
@@ -53614,20 +53614,21 @@ exports.draw = function (txt, id, ver) {
|
|||||||
"orient": "auto",
|
"orient": "auto",
|
||||||
"viewBox": "0,0,10,10"
|
"viewBox": "0,0,10,10"
|
||||||
}).append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z");
|
}).append("svg:path").attr("d", "M 0 0 L 10 5 L 0 10 z");
|
||||||
|
var count = commits.length;
|
||||||
var nodes = svg.selectAll("g.commit").data(commits).enter().append("g").attr("class", "commit").attr("id", function (d) {
|
var nodes = svg.selectAll("g.commit").data(commits).enter().append("g").attr("class", "commit").attr("id", function (d) {
|
||||||
return d.id;
|
return d.id;
|
||||||
}).attr("transform", function (d, i) {
|
}).attr("transform", function (d, i) {
|
||||||
if (direction == "TB" || direction == "BT") return "translate(50," + (50 + i * 100) + ")";
|
if (direction == "TB" || direction == "BT") return "translate(50," + (50 + i * 100) + ")";
|
||||||
if (direction == "LR") return "translate(" + (50 + i * 100) + ", 50)";
|
if (direction == "LR") return "translate(" + (50 + (count - i) * 100) + ", 50)";
|
||||||
});
|
});
|
||||||
|
|
||||||
var lines = svg.selectAll("g.arrows").data(commits).enter().append("g").append("line").attr("transform", function (d, i) {
|
var lines = svg.selectAll("g.arrows").data(commits).enter().append("g").append("line").attr("transform", function (d, i) {
|
||||||
if (direction == "TB" || direction == "BT") return "translate(50," + (70 + i * 100) + ")";
|
if (direction == "TB" || direction == "BT") return "translate(50," + (70 + i * 100) + ")";
|
||||||
if (direction == "LR") return "translate(" + (70 + i * 100) + ", 50)";
|
if (direction == "LR") return "translate(" + (70 + i * 100) + ", 50)";
|
||||||
}).attr({
|
}).attr({
|
||||||
"x1": direction == "LR" ? 0 : 0,
|
"x1": direction == "LR" ? 60 : 0,
|
||||||
"y1": direction == "LR" ? 0 : 0,
|
"y1": direction == "LR" ? 0 : 0,
|
||||||
"x2": direction == "LR" ? 60 : 0,
|
"x2": direction == "LR" ? 0 : 0,
|
||||||
"y2": direction == "LR" ? 0 : 60
|
"y2": direction == "LR" ? 0 : 60
|
||||||
}).attr("marker-end", "url(#triangle)").attr("stroke", "black").attr("stroke-width", "3");
|
}).attr("marker-end", "url(#triangle)").attr("stroke", "black").attr("stroke-width", "3");
|
||||||
//g.append('text') // text label for the x axis
|
//g.append('text') // text label for the x axis
|
||||||
|
@@ -43,6 +43,7 @@ exports.draw = function (txt, id, ver) {
|
|||||||
})
|
})
|
||||||
.append("svg:path")
|
.append("svg:path")
|
||||||
.attr("d", "M 0 0 L 10 5 L 0 10 z");
|
.attr("d", "M 0 0 L 10 5 L 0 10 z");
|
||||||
|
var count = commits.length;
|
||||||
var nodes = svg
|
var nodes = svg
|
||||||
.selectAll("g.commit")
|
.selectAll("g.commit")
|
||||||
.data(commits)
|
.data(commits)
|
||||||
@@ -56,7 +57,7 @@ exports.draw = function (txt, id, ver) {
|
|||||||
if (direction == "TB" || direction == "BT")
|
if (direction == "TB" || direction == "BT")
|
||||||
return "translate(50," + (50 + i * 100) + ")";
|
return "translate(50," + (50 + i * 100) + ")";
|
||||||
if (direction == "LR")
|
if (direction == "LR")
|
||||||
return "translate(" + (50 + i * 100) + ", 50)";
|
return "translate(" + (50 + (count -i) * 100) + ", 50)";
|
||||||
});
|
});
|
||||||
|
|
||||||
var lines = svg.selectAll("g.arrows")
|
var lines = svg.selectAll("g.arrows")
|
||||||
@@ -71,9 +72,9 @@ exports.draw = function (txt, id, ver) {
|
|||||||
return "translate(" + (70 + (i * 100)) + ", 50)";
|
return "translate(" + (70 + (i * 100)) + ", 50)";
|
||||||
})
|
})
|
||||||
.attr({
|
.attr({
|
||||||
"x1": direction == "LR" ? 0:0,
|
"x1": direction == "LR" ? 60:0,
|
||||||
"y1": direction == "LR" ? 0:0,
|
"y1": direction == "LR" ? 0:0,
|
||||||
"x2": direction == "LR" ? 60:0,
|
"x2": direction == "LR" ? 0:0,
|
||||||
"y2": direction == "LR" ? 0:60
|
"y2": direction == "LR" ? 0:60
|
||||||
})
|
})
|
||||||
.attr("marker-end", "url(#triangle)")
|
.attr("marker-end", "url(#triangle)")
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
gitGraph TB:
|
gitGraph :
|
||||||
commit
|
commit
|
||||||
branch newbranch
|
branch newbranch
|
||||||
checkout newbranch
|
checkout newbranch
|
||||||
|
Reference in New Issue
Block a user