You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`onClick`|`func`|||`undefined`| Callback function to be called whenever a node is clicked. <br /><br /> The clicked node's data object is passed to the callback function as the first parameter. |
85
-
|`orientation`|`string` (enum) |`horizontal``vertical`||`horizontal`|`horizontal` - Tree expands left-to-right. <br /><br /> `vertical` - Tree expands top-to-bottom. |
86
-
|`translate`|`object`|||`{x: 0, y: 0}`| Translates the graph along the x/y axis by the specified amount of pixels (avoids the graph being stuck in the top left canvas corner). |
87
-
|`pathFunc`|`string` (enum) |`diagonal``elbow``straight`||`diagonal`|`diagonal` - Renders smooth, curved edges between parent-child nodes. <br /><br /> `elbow` - Renders sharp edges at right angles between parent-child nodes. <br /><br /> `straight` - Renders straight lines between parent-child nodes. |
88
-
|`collapsible`|`bool`|||`true`| Toggles ability to collapse/expand the tree's nodes by clicking them. |
89
-
|`initialDepth`|`number`|`0..n`||`undefined`| Sets the maximum node depth to which the tree is expanded on its initial render. <br /> Tree renders to full depth if prop is omitted. |
90
-
|`depthFactor`|`number`|`-n..0..n`||`undefined`| Ensures the tree takes up a fixed amount of space (`node.y = node.depth * depthFactor`), regardless of tree depth. <br /> **TIP**: Negative values invert the tree's direction. |
91
-
|`zoomable`|`bool`|||`true`| Toggles ability to zoom in/out on the Tree by scaling it according to `props.scaleExtent`. |
92
-
|`scaleExtent`|`object`|`{min: 0..n, max: 0..n}`||`{min: 0.1, max: 1}`| Sets the minimum/maximum extent to which the tree can be scaled if `props.zoomable` is true. |
93
-
|`nodeSize`|`object`|`{x: 0..n, y: 0..n}`||`{x: 140, y: 140}`| Sets a fixed size for each node. <br /><br /> This does not affect node circle sizes, circle sizes are handled by the `circleRadius` prop. |
94
-
|`separation`|`object`|`{siblings: 0..n, nonSiblings: 0..n}`||`{siblings: 1, nonSiblings: 2}`| Sets separation between neighbouring nodes, differentiating between siblings (same parent) and non-siblings. |
95
-
|`circleRadius`|`number`|`0..n`||`10`| Sets the radius of each node's `<circle>` element. |
96
-
|`transitionDuration`|`number`|`0..n`||`500`| Sets the animation duration (in ms) of each expansion/collapse of a tree node. <br /><br /> Set this to `0` to deactivate animations completely. |
97
-
|`styles`|`object`| see [Styling](#styling)||`Node`/`Link` CSS files | Overrides and/or enhances the tree's default styling. |
|`nodeSvgShape`|`object`| see [Node shapes](#node-shapes)||`{shape: 'circle', shapeProps: r: 10}`| Sets a specific SVG shape element + shapeProps to be used for each node. |
86
+
|`onClick`|`func`|||`undefined`| Callback function to be called whenever a node is clicked. <br /><br /> The clicked node's data object is passed to the callback function as the first parameter. |
87
+
|`orientation`|`string` (enum) |`horizontal``vertical`||`horizontal`|`horizontal` - Tree expands left-to-right. <br /><br /> `vertical` - Tree expands top-to-bottom. |
88
+
|`translate`|`object`|||`{x: 0, y: 0}`| Translates the graph along the x/y axis by the specified amount of pixels (avoids the graph being stuck in the top left canvas corner). |
89
+
|`pathFunc`|`string` (enum) |`diagonal``elbow``straight`||`diagonal`|`diagonal` - Renders smooth, curved edges between parent-child nodes. <br /><br /> `elbow` - Renders sharp edges at right angles between parent-child nodes. <br /><br /> `straight` - Renders straight lines between parent-child nodes. |
90
+
|`collapsible`|`bool`|||`true`| Toggles ability to collapse/expand the tree's nodes by clicking them. |
91
+
|`initialDepth`|`number`|`0..n`||`undefined`| Sets the maximum node depth to which the tree is expanded on its initial render. <br /> Tree renders to full depth if prop is omitted. |
92
+
|`depthFactor`|`number`|`-n..0..n`||`undefined`| Ensures the tree takes up a fixed amount of space (`node.y = node.depth * depthFactor`), regardless of tree depth. <br /> **TIP**: Negative values invert the tree's direction. |
93
+
|`zoomable`|`bool`|||`true`| Toggles ability to zoom in/out on the Tree by scaling it according to `props.scaleExtent`. |
94
+
|`scaleExtent`|`object`|`{min: 0..n, max: 0..n}`||`{min: 0.1, max: 1}`| Sets the minimum/maximum extent to which the tree can be scaled if `props.zoomable` is true. |
95
+
|`nodeSize`|`object`|`{x: 0..n, y: 0..n}`||`{x: 140, y: 140}`| Sets a fixed size for each node. <br /><br /> This does not affect node circle sizes, circle sizes are handled by the `circleRadius` prop. |
96
+
|`separation`|`object`|`{siblings: 0..n, nonSiblings: 0..n}`||`{siblings: 1, nonSiblings: 2}`| Sets separation between neighbouring nodes, differentiating between siblings (same parent) and non-siblings. |
97
+
|`transitionDuration`|`number`|`0..n`||`500`| Sets the animation duration (in ms) of each expansion/collapse of a tree node. <br /><br /> Set this to `0` to deactivate animations completely. |
98
+
|`styles`|`object`| see [Styling](#styling)||`Node`/`Link` CSS files | Overrides and/or enhances the tree's default styling. |
99
+
|`circleRadius` (legacy) |`number`|`0..n`||`undefined`| Sets the radius of each node's `<circle>` element.<br /><br /> **Will be deprecated in v2, please use `nodeSvgShape` instead.**|
100
+
101
+
102
+
## Node shapes
103
+
The `nodeSvgShape` prop allows specifying any [SVG shape primitive](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Basic_Shapes) to describe how the tree's nodes should be shaped.
104
+
105
+
> Note: `nodeSvgShape` and `circleRadius` are mutually exclusive props. `nodeSvgShape` will be used unless the legacy `circleRadius` is specified.
106
+
107
+
For example, assuming we want to use squares instead of the default circles, we can do:
108
+
```js
109
+
constsvgSquare= {
110
+
shape:'rect',
111
+
shapeProps: {
112
+
width:20,
113
+
height:20,
114
+
x:-10,
115
+
y:-10,
116
+
}
117
+
}
118
+
119
+
// ...
120
+
121
+
<Tree data={myTreeData} nodeSvgShape={svgSquare}>
122
+
```
123
+
124
+
### Overridable `shapeProps`
125
+
`shapeProps` is currently merged with `node.circle`/`leafNode.circle` (see [Styling](#styling)).
126
+
127
+
This means any properties passed in `shapeProps` will be overridden by **properties with the same key** in the `node.circle`/`leafNode.circle` style props.
128
+
This is to prevent breaking the legacy usage of `circleRadius` + styling via `node/leafNode` properties until it is deprecated fully in v2.
98
129
130
+
**From v1.5.x onwards, it is therefore recommended to pass all node styling properties through `shapeProps`**.
99
131
100
132
## Styling
101
133
The tree's `styles` prop may be used to override any of the tree's default styling.
0 commit comments