lib/d3-flextree.js
function renormalize(wt) {

    // If a fixed tree size is specified, scale x and y based on the extent.
    // Compute the left-most, right-most, and depth-most nodes for extents.
    if (size != null) {
      var left = wt,
          right = wt,
          bottom = wt;
      var toVisit = [wt],
          node;
      while (node = toVisit.pop()) {
        var t = node.t;
        if (t.x < left.t.x) left = node;
        if (t.x > right.t.x) right = node;
        if (t.depth > bottom.t.depth) bottom = node;
        if (node.children) 
          toVisit = toVisit.concat(node.children);
      }

      var sep = separation == null ? 0.5 : separation(left.t, right.t)/2;
      var tx = sep - left.t.x;
      var kx = size[0] / (right.t.x + sep + tx);
      var ky = size[1] / (bottom.t.depth > 0 ? bottom.t.depth : 1);

      toVisit = [wt];
      while (node = toVisit.pop()) {
        var t = node.t;
        t.x = (t.x + tx) * kx;
        t.y = t.depth * ky;
        if (setNodeSizes) {
          t.x_size *= kx;
          t.y_size *= ky;
        }
        if (node.children) 
          toVisit = toVisit.concat(node.children);
      }
    }

    // Else either a fixed node size, or node size function was specified.
    // In this case, we translate such that the root node is at x = 0.
    else {
      var rootX = wt.t.x;
      moveRight(wt, -rootX);
    }
  }
function renormalize(wt) {

    // If a fixed tree size is specified, scale x and y based on the extent.
    // Compute the left-most, right-most, and depth-most nodes for extents.
    if (size != null) {
      var left = wt,
          right = wt,
          bottom = wt;
      var toVisit = [wt],
          node;
      while (node = toVisit.pop()) {
        var t = node.t;
        if (t.x < left.t.x) left = node;
        if (t.x > right.t.x) right = node;
        if (t.depth > bottom.t.depth) bottom = node;
        if (node.children) 
          toVisit = toVisit.concat(node.children);
      }

      var sep = separation == null ? 0.5 : separation(left.t, right.t)/2;
      var tx = sep - left.t.x;
      var kx = size[0] / (right.t.x + sep + tx);
      var ky = size[1] / (bottom.t.depth > 0 ? bottom.t.depth : 1);

      toVisit = [wt];
      while (node = toVisit.pop()) {
        var t = node.t;
        t.x = (t.x + tx) * kx;
        t.y = t.depth * ky;
        if (setNodeSizes) {
          t.x_size *= kx;
          t.y_size *= ky;
        }
        if (node.children) 
          toVisit = toVisit.concat(node.children);
      }
    }

    // Else either a fixed node size, or node size function was specified.
    // In this case, we translate such that the root node is at x = 0.
    else {
      var rootX = wt.t.x;
      moveRight(wt, -rootX);
    }
  }
function renormalize ( wt ) { // If a fixed tree size is specified, scale x and y based on the extent. // Compute the left-most, right-most, and depth-most nodes for extents. if ( size != null ) { var left = wt , right = wt , bottom = wt ; var toVisit = [ wt ] , node ; while ( node = toVisit . pop ( ) ) { var t = node . t ; if ( t . x < left . t . x ) left = node ; if ( t . x > right . t . x ) right = node ; if ( t . depth > bottom . t . depth ) bottom = node ; if ( node . children ) toVisit = toVisit . concat ( node . children ) ; } var sep = separation == null ? 0.5 : separation ( left . t , right . t ) / 2 ; var tx = sep - left . t . x ; var kx = size [ 0 ] / ( right . t . x + sep + tx ) ; var ky = size [ 1 ] / ( bottom . t . depth > 0 ? bottom . t . depth : 1 ) ; toVisit = [ wt ] ; while ( node = toVisit . pop ( ) ) { var t = node . t ; t . x = ( t . x + tx ) * kx ; t . y = t . depth * ky ; if ( setNodeSizes ) { t . x_size *= kx ; t . y_size *= ky ; } if ( node . children ) toVisit = toVisit . concat ( node . children ) ; } } // Else either a fixed node size, or node size function was specified. // In this case, we translate such that the root node is at x = 0. else { var rootX = wt . t . x ; moveRight ( wt , - rootX ) ; } }
Renormalize the coordinates
Renormalize the coordinates