From 43ab44d8ba736d80771dfd27109f35deba49efe6 Mon Sep 17 00:00:00 2001 From: Raghu Rajagopalan Date: Wed, 30 Mar 2016 15:05:35 +0530 Subject: [PATCH] fix LR layout - node position and arrow direction. --- dist/www/javascripts/lib/mermaid.js | 7 ++++--- src/diagrams/gitGraph/gitGraphRenderer.js | 7 ++++--- testgitgraph.mm | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dist/www/javascripts/lib/mermaid.js b/dist/www/javascripts/lib/mermaid.js index 396adb068..564d7b234 100644 --- a/dist/www/javascripts/lib/mermaid.js +++ b/dist/www/javascripts/lib/mermaid.js @@ -53614,20 +53614,21 @@ exports.draw = function (txt, id, ver) { "orient": "auto", "viewBox": "0,0,10,10" }).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) { return d.id; }).attr("transform", function (d, i) { 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) { if (direction == "TB" || direction == "BT") return "translate(50," + (70 + i * 100) + ")"; if (direction == "LR") return "translate(" + (70 + i * 100) + ", 50)"; }).attr({ - "x1": direction == "LR" ? 0 : 0, + "x1": direction == "LR" ? 60 : 0, "y1": direction == "LR" ? 0 : 0, - "x2": direction == "LR" ? 60 : 0, + "x2": direction == "LR" ? 0 : 0, "y2": direction == "LR" ? 0 : 60 }).attr("marker-end", "url(#triangle)").attr("stroke", "black").attr("stroke-width", "3"); //g.append('text') // text label for the x axis diff --git a/src/diagrams/gitGraph/gitGraphRenderer.js b/src/diagrams/gitGraph/gitGraphRenderer.js index 3fbc98c5a..e59fed746 100644 --- a/src/diagrams/gitGraph/gitGraphRenderer.js +++ b/src/diagrams/gitGraph/gitGraphRenderer.js @@ -43,6 +43,7 @@ exports.draw = function (txt, id, ver) { }) .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) @@ -56,7 +57,7 @@ exports.draw = function (txt, id, ver) { if (direction == "TB" || direction == "BT") return "translate(50," + (50 + i * 100) + ")"; if (direction == "LR") - return "translate(" + (50 + i * 100) + ", 50)"; + return "translate(" + (50 + (count -i) * 100) + ", 50)"; }); var lines = svg.selectAll("g.arrows") @@ -71,9 +72,9 @@ exports.draw = function (txt, id, ver) { return "translate(" + (70 + (i * 100)) + ", 50)"; }) .attr({ - "x1": direction == "LR" ? 0:0, + "x1": direction == "LR" ? 60:0, "y1": direction == "LR" ? 0:0, - "x2": direction == "LR" ? 60:0, + "x2": direction == "LR" ? 0:0, "y2": direction == "LR" ? 0:60 }) .attr("marker-end", "url(#triangle)") diff --git a/testgitgraph.mm b/testgitgraph.mm index 177bd144d..611837d2e 100644 --- a/testgitgraph.mm +++ b/testgitgraph.mm @@ -1,4 +1,4 @@ -gitGraph TB: +gitGraph : commit branch newbranch checkout newbranch