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
// This is a simplified example of an org chart with a depth of 2.
64
+
// Note how deeper levels are defined recursively via the `children` property.
59
65
constorgChartJson= {
60
66
name:'CEO',
61
67
children: [
@@ -72,7 +78,7 @@ const orgChartJson = {
72
78
},
73
79
children: [
74
80
{
75
-
name:'Workers',
81
+
name:'Worker',
76
82
},
77
83
],
78
84
},
@@ -83,7 +89,7 @@ const orgChartJson = {
83
89
},
84
90
children: [
85
91
{
86
-
name:'Workers',
92
+
name:'Worker',
87
93
},
88
94
],
89
95
},
@@ -105,6 +111,94 @@ export default function OrgChartTree() {
105
111
## Props
106
112
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
113
114
+
<!--(TODO: REVISE TITLE) -->
115
+
## Up & Running
116
+
### Styling nodes
117
+
`Tree` provides the following props to style different types of nodes, all of which use an SVG `circle` by default:
118
+
119
+
-`rootNodeClassName` - will be applied to the root node.
120
+
-`branchNodeClassName` - will be applied to any node with 1+ children.
121
+
-`leafNodeClassName` - will be applied to any node without children.
122
+
123
+
To visually distinguish these three types of nodes from each other by color, we could provide each with their own class:
> For more details on the `className` props for nodes, see the [TreeProps reference docs](https://bkrem.github.io/react-d3-tree/docs/interfaces/_tree_types_.treeprops.html).
163
+
164
+
<!-- For a full list of options of CSS properties that can be used for the default nodes, check the SVG circle [specification](TODO:) -->
165
+
166
+
### Styling links
167
+
`Tree` provides the `pathClassFunc` property to pass additional classNames to every link to be rendered.
168
+
169
+
Each link calls `pathClassFunc` with its own `TreeLinkDatum` and the tree's current `orientation`. `Tree` expects `pathClassFunc` to return a `className` string.
// Dynamically determine which `className` to pass based on the link's properties.
191
+
pathClassFunc={getDynamicPathClass}
192
+
/>
193
+
);
194
+
}
195
+
```
196
+
197
+
> For more details, see the `PathClassFunction`[reference docs](https://bkrem.github.io/react-d3-tree/docs/modules/_types_common_.html#pathclassfunction).
198
+
199
+
## Rendering custom nodes
200
+
TODO:
201
+
108
202
## Development
109
203
### Setup
110
204
To set up `react-d3-tree` for local development, clone the repo and follow the steps below:
0 commit comments