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
-[Providing your own `pathFunc`](#providing-your-own-pathfunc)
41
41
-[Development](#development)
42
42
-[Setup](#setup)
43
43
-[Hot reloading](#hot-reloading)
@@ -104,18 +104,16 @@ export default function OrgChartTree() {
104
104
```
105
105
106
106
## Props
107
-
For details on the props accepted by `Tree`, check out the [TreeProps reference docs](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html).
107
+
For details on all props accepted by `Tree`, check out the [TreeProps reference docs](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html).
108
108
109
-
The only required prop is [data](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html#data), all other props on `Tree` are optional/pre-defined (see "Default value" on each prop).
109
+
The only required prop is [data](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html#data), all other props on `Tree` are optional/pre-defined (see "Default value" on each prop definition).
110
110
111
-
<!--(TODO: REVISE TITLE) -->
112
-
## Up & Running
113
-
### Styling Nodes
111
+
## Styling Nodes
114
112
`Tree` provides the following props to style different types of nodes, all of which use an SVG `circle` by default:
115
113
116
-
-`rootNodeClassName` - will be applied to the root node.
117
-
-`branchNodeClassName` - will be applied to any node with 1+ children.
118
-
-`leafNodeClassName` - will be applied to any node without children.
114
+
-`rootNodeClassName` - applied to the root node.
115
+
-`branchNodeClassName` - applied to any node with 1+ children.
116
+
-`leafNodeClassName` - applied to any node without children.
119
117
120
118
To visually distinguish these three types of nodes from each other by color, we could provide each with their own class:
121
119
@@ -161,7 +159,7 @@ export default function StyledNodesTree() {
161
159
162
160
<!-- For a full list of options of CSS properties that can be used for the default nodes, check the SVG circle [specification](TODO:) -->
163
161
164
-
###Styling Links
162
+
## Styling Links
165
163
`Tree` provides the `pathClassFunc` property to pass additional classNames to every link to be rendered.
166
164
167
165
Each link calls `pathClassFunc` with its own `TreeLinkDatum` and the tree's current `orientation`. `Tree` expects `pathClassFunc` to return a `className` string.
@@ -194,7 +192,7 @@ function StyledLinksTree() {
194
192
195
193
> For more details, see the `PathClassFunction`[reference docs](https://bkrem.github.io/react-d3-tree/docs/modules/_types_common_.html#pathclassfunction).
196
194
197
-
###Event Handlers
195
+
## Event Handlers
198
196
`Tree` exposes the following event handler callbacks by default:
@@ -220,7 +218,41 @@ Cases where you may find rendering your own `Node` element useful include:
220
218
- Building **richer & more complex nodes/labels** by leveraging the `foreignObject` tag to render HTML inside the SVG namespace - [Example (codesandbox.io)](https://codesandbox.io/s/rd3t-v2-custom-with-foreignobject-0mfj8?file=/src/App.js)
221
219
222
220
### `pathFunc`
223
-
TODO
221
+
The [`pathFunc` prop](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html#pathfunc) accepts a predefined `PathFunctionOption` enum or a user-defined `PathFunction`.
222
+
223
+
By changing or providing your own `pathFunc`, you are able to change how links between nodes of the tree (which are SVG `path` tags under the hood) are drawn.
224
+
225
+
The currently [available enums](https://bkrem.github.io/react-d3-tree/docs/modules/_types_common_.html#pathfunctionoption) are:
226
+
-`diagonal` (default)
227
+
-`elbow`
228
+
-`straight`
229
+
-`step`
230
+
231
+
> Want to see how each option looks? [Try them out on the playground](https://bkrem.github.io/react-d3-tree).
232
+
233
+
#### Providing your own `pathFunc`
234
+
If none of the available path functions suit your needs, you're also able to provide a custom `PathFunction`:
0 commit comments