Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate cluster padding top/bottom #242

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/dagre.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function updateInputGraph(inputGraph, layoutGraph) {
inputGraph.graph().height = layoutGraph.graph().height;
}

var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"],
graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" },
var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy", "clusterpaddingtop", "clusterpaddingbottom"],
graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb", clusterpaddingtop: 20, clusterpaddingbottom: 20 },
graphAttrs = ["acyclicer", "ranker", "rankdir", "align"],
nodeNumAttrs = ["width", "height"],
nodeDefaults = { width: 0, height: 0 },
Expand Down
11 changes: 7 additions & 4 deletions lib/position/bk.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function horizontalCompaction(g, layering, root, align, reverseSep) {
function buildBlockGraph(g, layering, root, reverseSep) {
var blockGraph = new Graph(),
graphLabel = g.graph(),
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep, graphLabel.clusterpaddingtop, graphLabel.clusterpaddingbottom);

_.forEach(layering, function(layer) {
var u;
Expand Down Expand Up @@ -376,7 +376,7 @@ function positionX(g) {
return balance(xss, g.graph().align);
}

function sep(nodeSep, edgeSep, reverseSep) {
function sep(nodeSep, edgeSep, reverseSep, clusterpaddingtop, clusterpaddingbottom) {
return function(g, v, w) {
var vLabel = g.node(v),
wLabel = g.node(w),
Expand All @@ -395,8 +395,11 @@ function sep(nodeSep, edgeSep, reverseSep) {
}
delta = 0;

sum += (vLabel.dummy ? edgeSep : nodeSep) / 2;
sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;
var vPadding = vLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop;
var wPadding = wLabel.borderType === "borderRight" ? clusterpaddingbottom : clusterpaddingtop;

sum += (vLabel.dummy ? vLabel.dummy === "border" ? vPadding : edgeSep : nodeSep) / 2;
sum += (wLabel.dummy ? wLabel.dummy === "border" ? wPadding : edgeSep : nodeSep) / 2;

sum += wLabel.width / 2;
if (_.has(wLabel, "labelpos")) {
Expand Down