@@ -197,16 +197,29 @@ export default class Tree extends React.Component {
197
197
/**
198
198
* generateTree - Generates tree elements (`nodes` and `links`) by
199
199
* grabbing the rootNode from `this.state.data[0]`.
200
- * Restricts tree depth to `props.initial ` if defined and this is
200
+ * Restricts tree depth to `props.initialDepth ` if defined and if this is
201
201
* the initial render of the tree.
202
202
*
203
- * @return {object } Object containing `nodes` and `links` fields .
203
+ * @return {object } Object containing `nodes` and `links`.
204
204
*/
205
205
generateTree ( ) {
206
- const { initialDepth, depthFactor, separation } = this . props ;
206
+ const {
207
+ initialDepth,
208
+ depthFactor,
209
+ separation,
210
+ nodeSize,
211
+ orientation,
212
+ } = this . props ;
213
+
207
214
const tree = layout . tree ( )
208
- . nodeSize ( [ 140 , 140 ] )
209
- . separation ( ( d ) => d . _children ? separation . node : separation . leafNode )
215
+ . nodeSize ( orientation === 'horizontal' ?
216
+ [ nodeSize . y , nodeSize . x ] :
217
+ [ nodeSize . x , nodeSize . y ]
218
+ )
219
+ . separation ( ( a , b ) => deepEqual ( a . parent , b . parent ) ?
220
+ separation . node :
221
+ separation . leafNode
222
+ )
210
223
. children ( ( d ) => d . _collapsed ? null : d . _children ) ;
211
224
212
225
const rootNode = this . state . data [ 0 ] ;
@@ -285,6 +298,7 @@ Tree.defaultProps = {
285
298
initialDepth : undefined ,
286
299
zoomable : true ,
287
300
scaleExtent : { min : 0.1 , max : 1 } ,
301
+ nodeSize : { x : 140 , y : 140 } ,
288
302
separation : { node : 1.2 , leafNode : 0.9 } ,
289
303
styles : {
290
304
nodes : {
@@ -326,6 +340,10 @@ Tree.propTypes = {
326
340
min : PropTypes . number ,
327
341
max : PropTypes . number ,
328
342
} ) ,
343
+ nodeSize : PropTypes . shape ( {
344
+ x : PropTypes . number ,
345
+ y : PropTypes . number ,
346
+ } ) ,
329
347
separation : PropTypes . shape ( {
330
348
node : PropTypes . number ,
331
349
leafNode : PropTypes . number ,
0 commit comments