updatePosition()

in src/vis/SentenTreeVis.js [136:168]


  updatePosition() {
    let yPos = 0;
    let maxw = 0;
    const { margin, gapBetweenGraph } = this.options();
    const { top, left, bottom, right } = margin;

    // Get bbox of <g> for each graph to compute total dimension
    // and stack each graph on top of each other
    this.sNodeGraphs.each(function fn(graph) {
      const bbox = this.getBBox();
      const w = bbox.width;
      const h = bbox.height;
      maxw = Math.max(w, maxw);
      graph.x = -bbox.x;
      graph.y = -bbox.y + yPos;
      yPos += h + gapBetweenGraph;
    });

    this.sNodeGraphs
      .attr('transform', graph => `translate(${graph.x},${graph.y})`);

    this.sLinkGraphs
      .attr('transform', graph => `translate(${graph.x},${graph.y})`);

    // Update component size to fit all content
    this.dimension([
      maxw + left + right,
      Math.max(0, yPos - gapBetweenGraph) + top + bottom,
    ]);

    this.placeNodes();
    this.placeLinks();
  }