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
* added 'zoom' property to set initial scale
* added 'onUpdate' callback prop
* added a clarification about 'the missing' onUpdate on drag
* fixed a spelling mistake
* fixed an incorrect type check
* onUpdate() now receives the entire node instead of its ID
* updated README.md
* scaleExtent constrains zoom level on initial display, not only when zooming with the mouse
* fixed inconsistencies when passing values to onUpdate under different circumstances; got rid of double rendering when setting initial tree depth
* onUpdate is now dependent only in internal tree state
* fixed onUpdate argument discrepancies in unit tests and the tree
* removed unnecessary D3 state overwrite
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,13 +88,15 @@ class MyComponent extends React.Component {
88
88
|`onClick`|`func`|||`undefined`| Callback function to be called when a node is clicked. <br /><br /> The clicked node's data object is passed to the callback function. |
89
89
|`onMouseOver`|`func`|||`undefined`| Callback function to be called when mouse enters the space belonging to a node. <br /><br /> The node's data object is passed to the callback. |
90
90
|`onMouseOut`|`func`|||`undefined`| Callback function to be called when mouse leaves the space belonging to a node. <br /><br /> The node's data object is passed to the callback. |
91
+
|`onUpdate`|`func`|||`undefined`| Callback function to be called when the inner D3 component updates. That is - on every zoom or translate event, or when tree branches are toggled. The node's data object, as well as zoom level and coordinates are passed to the callback. |
91
92
|`orientation`|`string` (enum) |`horizontal``vertical`||`horizontal`|`horizontal` - Tree expands left-to-right. <br /><br /> `vertical` - Tree expands top-to-bottom. |
92
93
|`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). |
93
94
|`pathFunc`|`string (enum)`/`func`|`diagonal`<br/>`elbow`<br/>`straight`<br/>`customFunc(linkData, orientation)`||`diagonal`|`diagonal` - Smooth, curved edges between parent-child nodes. <br /><br /> `elbow` - Sharp edges at right angles between parent-child nodes. <br /><br /> `straight` - Straight lines between parent-child nodes. <br /><br /> `customFunc` - Custom draw function that accepts `linkData` as its first param and `orientation` as its second. |
94
95
|`collapsible`|`bool`|||`true`| Toggles ability to collapse/expand the tree's nodes by clicking them. |
95
96
|`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. |
96
97
|`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. |
97
98
|`zoomable`|`bool`|||`true`| Toggles ability to zoom in/out on the Tree by scaling it according to `props.scaleExtent`. |
99
+
|`zoom`|`number`|`0..n`||`1`| A floating point number to set the initial zoom level. It is constrained by `props.scaleExtent`. `1` is the default "non-zoomed" level. |
98
100
|`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. |
99
101
|`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. |
100
102
|`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. |
0 commit comments