An open API service indexing awesome lists of open source software.

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 🌳

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