@@ -5779,7 +5779,7 @@ d3 = function() {
57795779 return [ d3 . min ( values ) , d3 . max ( values ) ] ;
57805780 }
57815781 d3 . layout . tree = function ( ) {
5782- var hierarchy = d3 . layout . hierarchy ( ) . sort ( null ) . value ( null ) , separation = d3_layout_treeSeparation , size = [ 1 , 1 ] ;
5782+ var hierarchy = d3 . layout . hierarchy ( ) . sort ( null ) . value ( null ) , separation = d3_layout_treeSeparation , size = [ 1 , 1 ] , nodeSize = false ;
57835783 function tree ( d , i ) {
57845784 var nodes = hierarchy . call ( this , d , i ) , root = nodes [ 0 ] ;
57855785 function firstWalk ( node , previousSibling ) {
@@ -5860,7 +5860,11 @@ d3 = function() {
58605860 firstWalk ( root ) ;
58615861 secondWalk ( root , - root . _tree . prelim ) ;
58625862 var left = d3_layout_treeSearch ( root , d3_layout_treeLeftmost ) , right = d3_layout_treeSearch ( root , d3_layout_treeRightmost ) , deep = d3_layout_treeSearch ( root , d3_layout_treeDeepest ) , x0 = left . x - separation ( left , right ) / 2 , x1 = right . x + separation ( right , left ) / 2 , y1 = deep . depth || 1 ;
5863- d3_layout_treeVisitAfter ( root , function ( node ) {
5863+ d3_layout_treeVisitAfter ( root , nodeSize ? function ( node ) {
5864+ node . x *= size [ 0 ] ;
5865+ node . y = node . depth * size [ 1 ] ;
5866+ delete node . _tree ;
5867+ } : function ( node ) {
58645868 node . x = ( node . x - x0 ) / ( x1 - x0 ) * size [ 0 ] ;
58655869 node . y = node . depth / y1 * size [ 1 ] ;
58665870 delete node . _tree ;
@@ -5873,8 +5877,13 @@ d3 = function() {
58735877 return tree ;
58745878 } ;
58755879 tree . size = function ( x ) {
5876- if ( ! arguments . length ) return size ;
5877- size = x ;
5880+ if ( ! arguments . length ) return nodeSize ? null : size ;
5881+ nodeSize = ( size = x ) == null ;
5882+ return tree ;
5883+ } ;
5884+ tree . nodeSize = function ( x ) {
5885+ if ( ! arguments . length ) return nodeSize ? size : null ;
5886+ nodeSize = ( size = x ) != null ;
58785887 return tree ;
58795888 } ;
58805889 return d3_layout_hierarchyRebind ( tree , hierarchy ) ;
@@ -6099,7 +6108,7 @@ d3 = function() {
60996108 }
61006109 }
61016110 d3 . layout . cluster = function ( ) {
6102- var hierarchy = d3 . layout . hierarchy ( ) . sort ( null ) . value ( null ) , separation = d3_layout_treeSeparation , size = [ 1 , 1 ] ;
6111+ var hierarchy = d3 . layout . hierarchy ( ) . sort ( null ) . value ( null ) , separation = d3_layout_treeSeparation , size = [ 1 , 1 ] , nodeSize = false ;
61036112 function cluster ( d , i ) {
61046113 var nodes = hierarchy . call ( this , d , i ) , root = nodes [ 0 ] , previousNode , x = 0 ;
61056114 d3_layout_treeVisitAfter ( root , function ( node ) {
@@ -6114,7 +6123,10 @@ d3 = function() {
61146123 }
61156124 } ) ;
61166125 var left = d3_layout_clusterLeft ( root ) , right = d3_layout_clusterRight ( root ) , x0 = left . x - separation ( left , right ) / 2 , x1 = right . x + separation ( right , left ) / 2 ;
6117- d3_layout_treeVisitAfter ( root , function ( node ) {
6126+ d3_layout_treeVisitAfter ( root , nodeSize ? function ( node ) {
6127+ node . x = ( node . x - root . x ) * size [ 0 ] ;
6128+ node . y = ( root . y - node . y ) * size [ 1 ] ;
6129+ } : function ( node ) {
61186130 node . x = ( node . x - x0 ) / ( x1 - x0 ) * size [ 0 ] ;
61196131 node . y = ( 1 - ( root . y ? node . y / root . y : 1 ) ) * size [ 1 ] ;
61206132 } ) ;
@@ -6126,8 +6138,13 @@ d3 = function() {
61266138 return cluster ;
61276139 } ;
61286140 cluster . size = function ( x ) {
6129- if ( ! arguments . length ) return size ;
6130- size = x ;
6141+ if ( ! arguments . length ) return nodeSize ? null : size ;
6142+ nodeSize = ( size = x ) == null ;
6143+ return cluster ;
6144+ } ;
6145+ cluster . nodeSize = function ( x ) {
6146+ if ( ! arguments . length ) return nodeSize ? size : null ;
6147+ nodeSize = ( size = x ) != null ;
61316148 return cluster ;
61326149 } ;
61336150 return d3_layout_hierarchyRebind ( cluster , hierarchy ) ;
0 commit comments