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
@@ -108,7 +110,31 @@ For details on all props accepted by `Tree`, check out the [TreeProps reference
108
110
109
111
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
112
111
-
## Styling Nodes
113
+
## Working with the default Tree
114
+
`react-d3-tree` provides default implementations for `Tree`'s nodes & links, which are intended to get you up & running with a working tree quickly.
115
+
116
+
This section is focused on explaining **how to provide data, styles and event handlers for the default `Tree` implementation**.
117
+
118
+
> Need more fine-grained control over how nodes & links appear/behave? Check out the [Customizing the Tree](#customizing-the-tree) section below.
119
+
120
+
### Providing `data`
121
+
By default, `Tree` expects each node object in `data` to implement the [`RawNodeDatum` interface](https://bkrem.github.io/react-d3-tree/docs/interfaces/_types_common_.rawnodedatum.html):
122
+
123
+
```ts
124
+
interfaceRawNodeDatum {
125
+
name:string;
126
+
attributes?:Record<string, string>;
127
+
children?:RawNodeDatum[];
128
+
}
129
+
```
130
+
131
+
The `orgChart` example in the [Usage](#usage) section above is an example of this:
132
+
133
+
- Every node has at least a `name`. This is rendered as the **node's primary label**.
134
+
- Some nodes have `attributes` defined (the `CEO` node does not). **The key-value pairs in `attributes` are rendered as a list of secondary labels**.
135
+
- Nodes can have further `RawNodeDatum` objects nested inside them via the `children` key, creating a hierarchy from which the tree graph can be generated.
136
+
137
+
### Styling Nodes
112
138
`Tree` provides the following props to style different types of nodes, all of which use an SVG `circle` by default:
113
139
114
140
-`rootNodeClassName` - applied to the root node.
@@ -129,7 +155,8 @@ To visually distinguish these three types of nodes from each other by color, we
129
155
}
130
156
131
157
.node__leaf>circle {
132
-
/* Let's make the radius of leaf nodes larger */
158
+
fill: green
159
+
/* Let's also make the radius of leaf nodes larger */
133
160
r: 40;
134
161
}
135
162
```
@@ -159,7 +186,7 @@ export default function StyledNodesTree() {
159
186
160
187
<!-- For a full list of options of CSS properties that can be used for the default nodes, check the SVG circle [specification](TODO:) -->
161
188
162
-
## Styling Links
189
+
###Styling Links
163
190
`Tree` provides the `pathClassFunc` property to pass additional classNames to every link to be rendered.
164
191
165
192
Each link calls `pathClassFunc` with its own `TreeLinkDatum` and the tree's current `orientation`. `Tree` expects `pathClassFunc` to return a `className` string.
@@ -192,7 +219,7 @@ function StyledLinksTree() {
192
219
193
220
> For more details, see the `PathClassFunction`[reference docs](https://bkrem.github.io/react-d3-tree/docs/modules/_types_common_.html#pathclassfunction).
194
221
195
-
## Event Handlers
222
+
###Event Handlers
196
223
`Tree` exposes the following event handler callbacks by default:
0 commit comments