Skip to content

Commit dd71e0a

Browse files
committed
Establishes separation prop (#13)
1 parent 1b6e6be commit dd71e0a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Tree/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ export default class Tree extends React.Component {
203203
* @return {object} Object containing `nodes` and `links` fields.
204204
*/
205205
generateTree() {
206-
const { initialDepth, depthFactor } = this.props;
206+
const { initialDepth, depthFactor, separation } = this.props;
207+
console.log(separation);
207208
const tree = layout.tree()
208209
.nodeSize([100 + 40, 100 + 40])
209-
.separation((d) => d._children ? 1.2 : 0.9)
210+
.separation((d) => d._children ? separation.node : separation.leafNode)
210211
.children((d) => d._collapsed ? null : d._children);
211212

212213
const rootNode = this.state.data[0];
@@ -285,6 +286,7 @@ Tree.defaultProps = {
285286
initialDepth: undefined,
286287
zoomable: true,
287288
scaleExtent: { min: 0.1, max: 1 },
289+
separation: { node: 1.2, leafNode: 0.9 },
288290
styles: {
289291
nodes: {
290292
node: {
@@ -325,6 +327,10 @@ Tree.propTypes = {
325327
min: PropTypes.number,
326328
max: PropTypes.number,
327329
}),
330+
separation: PropTypes.shape({
331+
node: PropTypes.number,
332+
leafNode: PropTypes.number,
333+
}),
328334
styles: PropTypes.shape({
329335
nodes: PropTypes.object,
330336
links: PropTypes.object,

0 commit comments

Comments
 (0)