@dagrejs/dagre 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dagre.js CHANGED
@@ -1858,6 +1858,7 @@ var dagre = (() => {
1858
1858
  function positionY(g) {
1859
1859
  let layering = util.buildLayerMatrix(g);
1860
1860
  let rankSep = g.graph().ranksep;
1861
+ let rankAlign = g.graph().rankalign;
1861
1862
  let prevY = 0;
1862
1863
  layering.forEach((layer) => {
1863
1864
  const maxHeight = layer.reduce((acc, v) => {
@@ -1868,7 +1869,16 @@ var dagre = (() => {
1868
1869
  return height;
1869
1870
  }
1870
1871
  }, 0);
1871
- layer.forEach((v) => g.node(v).y = prevY + maxHeight / 2);
1872
+ layer.forEach((v) => {
1873
+ let node = g.node(v);
1874
+ if (rankAlign === "top") {
1875
+ node.y = prevY + node.height / 2;
1876
+ } else if (rankAlign === "bottom") {
1877
+ node.y = prevY + maxHeight - node.height / 2;
1878
+ } else {
1879
+ node.y = prevY + maxHeight / 2;
1880
+ }
1881
+ });
1872
1882
  prevY += maxHeight + rankSep;
1873
1883
  });
1874
1884
  }
@@ -1959,8 +1969,8 @@ var dagre = (() => {
1959
1969
  inputGraph.graph().height = layoutGraph.graph().height;
1960
1970
  }
1961
1971
  var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
1962
- var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
1963
- var graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
1972
+ var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb", rankalign: "center" };
1973
+ var graphAttrs = ["acyclicer", "ranker", "rankdir", "align", "rankalign"];
1964
1974
  var nodeNumAttrs = ["width", "height", "rank"];
1965
1975
  var nodeDefaults = { width: 0, height: 0 };
1966
1976
  var edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
@@ -2269,7 +2279,7 @@ var dagre = (() => {
2269
2279
  // lib/version.js
2270
2280
  var require_version = __commonJS({
2271
2281
  "lib/version.js"(exports, module) {
2272
- module.exports = "2.0.1";
2282
+ module.exports = "2.0.4";
2273
2283
  }
2274
2284
  });
2275
2285