Skip to content

Commit b3657cd

Browse files
committed
docs: cleanup
1 parent d57ce46 commit b3657cd

File tree

1 file changed

+1
-128
lines changed

1 file changed

+1
-128
lines changed

README.md

Lines changed: 1 addition & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ React D3 Tree is a [React](http://facebook.github.io/react/) component that lets
4141
- [FAQ](#faq)
4242
- [Contributors](#contributors)
4343
- [License](#license)
44-
- [Keeping large trees responsive](#keeping-large-trees-responsive)
45-
- [External data sources](#external-data-sources)
46-
- [Example](#example)
47-
- [Using foreignObjects](#using-foreignobjects)
48-
- [`nodeLabelComponent`](#nodelabelcomponent)
49-
- [Example](#example-1)
50-
- [Recipes](#recipes)
51-
- [Auto-centering inside `treeContainer`](#auto-centering-inside-treecontainer)
5244

5345
## Installation
5446
```bash
@@ -157,8 +149,6 @@ export default function StyledNodesTree() {
157149
}
158150
```
159151

160-
TODO: link to TreeProps page
161-
162152
> 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).
163153
164154
<!-- For a full list of options of CSS properties that can be used for the default nodes, check the SVG circle [specification](TODO:) -->
@@ -236,121 +226,4 @@ npm start
236226
-- TODO --
237227

238228
## License
239-
MIT
240-
241-
----
242-
243-
## Keeping large trees responsive
244-
Attempting to render large trees with animated transitions may cause significant input lag. This is due to limitations related to the way D3's `select().transition()` enqueues calls to `requestAnimationFrame`, discussed [here](https://github.com/bkrem/react-d3-tree/issues/41#issuecomment-338425414).
245-
246-
Until a custom debounce for expand/collapse has been implemented, **it is therefore recommended to set `props.transitionDuration` to `0` for large tree graphs** if you're experiencing responsiveness issues.
247-
248-
249-
## External data sources
250-
Statically hosted JSON or CSV files can be used as data sources via the additional `treeUtil` module.
251-
252-
### Example
253-
254-
```jsx
255-
import React from 'react';
256-
import { Tree, treeUtil } from 'react-d3-tree';
257-
258-
const csvSource = 'https://raw.githubusercontent.com/bkrem/react-d3-tree/master/docs/examples/data/csv-example.csv';
259-
260-
constructor() {
261-
super();
262-
263-
this.state = {
264-
data: undefined,
265-
};
266-
}
267-
268-
componentWillMount() {
269-
treeUtil.parseCSV(csvSource)
270-
.then((data) => {
271-
this.setState({ data })
272-
})
273-
.catch((err) => console.error(err));
274-
}
275-
276-
class MyComponent extends React.Component {
277-
render() {
278-
return (
279-
     {/* <Tree /> will fill width/height of its container; in this case `#treeWrapper` */}
280-
<div id="treeWrapper" style={{width: '50em', height: '20em'}}>
281-
282-
<Tree data={this.state.data} />
283-
284-
</div>
285-
);
286-
}
287-
}
288-
```
289-
290-
For details regarding the `treeUtil` module, please check the module's [API docs](docs/util/util.md).
291-
For examples of each data type that can be parsed with `treeUtil`, please check the [data source examples](docs/examples/data).
292-
293-
294-
## Using foreignObjects
295-
> ⚠️ Requires `allowForeignObjects` prop to be set due to limited browser support: [IE does not currently support `foreignObject` elements](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject#Browser_compatibility).
296-
297-
> ⚠️ There is a [known bug in Safari](https://github.com/bkrem/react-d3-tree/issues/284) relating to the positioning of `foreignObject` elements. Please take this into account before opting in via `allowForeignObjects`.
298-
299-
The SVG spec's `foreignObject` element allows foreign XML content to be rendered into the SVG namespace, unlocking the ability to use regular React components for elements of the tree graph.
300-
301-
### `nodeLabelComponent`
302-
The `nodeLabelComponent` prop provides a way to use a React component for each node's label. It accepts an object with the following signature:
303-
```ts
304-
{
305-
render: ReactElement,
306-
foreignObjectWrapper?: object
307-
}
308-
```
309-
* `render` is the XML React-D3-Tree will use to render each node's label.
310-
* `foreignObjectWrapper` contains a set of attributes that should be passed to the `<foreignObject />` that wraps `nodeLabelComponent`. For possible attributes please check the [spec](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject#Global_attributes).
311-
312-
**Note: By default, `foreignObjectWrapper` will set its width and height attributes to `nodeSize.x - 24px` and `nodeSize.y - 24px` respectively; where a base margin of 24px is subtracted to avoid the overlapping of elements.**
313-
To override this behaviour for each attribute, specify `width` and/or `height` properties for your `foreignObjectWrapper`.
314-
315-
**Note:** The ReactElement passed to `render` is cloned with its existing props and **receives an additional `nodeData` object prop, containing information about the current node.**
316-
317-
#### Example
318-
Assuming we have a React component `NodeLabel` and we want to avoid node's label overlapping with the node itself by moving its position along the Y-axis, we could implement `nodeLabelComponent` like so:
319-
```jsx
320-
class NodeLabel extends React.PureComponent {
321-
render() {
322-
const {className, nodeData} = this.props
323-
return (
324-
<div className={className}>
325-
<h2>{nodeData.name}</h2>
326-
{nodeData._children &&
327-
<button>{nodeData._collapsed ? 'Expand' : 'Collapse'}</button>
328-
}
329-
</div>
330-
)
331-
}
332-
}
333-
334-
/* ... */
335-
336-
render() {
337-
return (
338-
<Tree
339-
data={myTreeData}
340-
allowForeignObjects
341-
nodeLabelComponent={{
342-
render: <NodeLabel className='myLabelComponentInSvg' />,
343-
foreignObjectWrapper: {
344-
y: 24
345-
}
346-
}}
347-
/>
348-
)
349-
}
350-
```
351-
352-
353-
354-
## Recipes
355-
#### [Auto-centering inside `treeContainer`](https://codesandbox.io/s/vvz51w5n63)
356-
229+
MIT

0 commit comments

Comments
 (0)