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

Allow positioner to be configurable #273

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
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = {
debug: require("./lib/debug"),
util: {
time: require("./lib/util").time,
notime: require("./lib/util").notime
notime: require("./lib/util").notime,
buildLayerMatrix: require("./lib/util").buildLayerMatrix
},
version: require("./lib/version")
};
2 changes: 1 addition & 1 deletion lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function updateInputGraph(inputGraph, layoutGraph) {

var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
var graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
var graphAttrs = ["acyclicer", "ranker", "positioner", "rankdir", "align"];
var nodeNumAttrs = ["width", "height"];
var nodeDefaults = { width: 0, height: 0 };
var edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
Expand Down
5 changes: 5 additions & 0 deletions lib/position/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ module.exports = position;
function position(g) {
g = util.asNonCompoundGraph(g);

var positioner = g.graph().positioner;
if (positioner instanceof Function) {
return positioner(g)
}

positionY(g);
_.forEach(positionX(g), function(x, v) {
g.node(v).x = x;
Expand Down