https://github.com/sanichkotikov/relatives-tree
A tiny library for calculating specific JSON data to family tree nodes and connectors 🌳
https://github.com/sanichkotikov/relatives-tree
es6-modules family-tree familytree graph-algorithms no-dependencies npm-module npm-package vanillajs
Last synced: about 1 year ago
JSON representation
A tiny library for calculating specific JSON data to family tree nodes and connectors 🌳
- Host: GitHub
- URL: https://github.com/sanichkotikov/relatives-tree
- Owner: SanichKotikov
- License: mit
- Created: 2018-12-26T19:36:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-23T20:39:25.000Z (over 1 year ago)
- Last Synced: 2025-04-03T03:36:05.558Z (over 1 year ago)
- Topics: es6-modules, family-tree, familytree, graph-algorithms, no-dependencies, npm-module, npm-package, vanillajs
- Language: TypeScript
- Homepage: https://sanichkotikov.github.io/react-family-tree-example/
- Size: 1.02 MB
- Stars: 50
- Watchers: 1
- Forks: 22
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# relatives-tree
A tiny library (~3.23 kB) for calculating JSON data to family tree nodes and connectors.
🖥 [DEMO APP](https://sanichkotikov.github.io/react-family-tree-example/)
## Installation
```bash
npm i relatives-tree
```
## Usage
```typescript
import calcTree, { type Node } from 'relatives-tree';
const nodes: Node[] = [
{
id: "1",
gender: "male",
spouses: [],
siblings: [],
parents: [],
children: [
{ id: "2", type: "blood" },
{ id: "3", type: "blood" }
]
},
{
id: "2",
gender: "female",
spouses: [],
siblings: [],
parents: [{ id: "1", type: "blood" }],
children: []
},
{
id: "3",
gender: "male",
spouses: [],
siblings: [],
parents: [{ id: "1", type: "blood" }],
children: []
}
];
const tree = calcTree(nodes, { rootId: "1" });
render(tree);
```
## Rendering Examples
🛠 [Canvas example](/docs)
🛠️ [React example](https://github.com/SanichKotikov/react-family-tree)
🛠️ [Solid example](https://github.com/SanichKotikov/solid-family-tree-example)
## Input Data Structure
📝 [JSON EXAMPLES](/samples)
## Contributing
Please read [this documentation](https://github.com/SanichKotikov/contributing) before contributing.
## License
MIT