Skip to content

SanichKotikov/relatives-tree

Repository files navigation

relatives-tree

A tiny library (~3.23 kB) for calculating JSON data to family tree nodes and connectors.

🖥 DEMO APP

Installation

npm i relatives-tree

Usage

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
🛠️ React example
🛠️ Solid example

Input Data Structure

📝 JSON EXAMPLES

Contributing

Please read this documentation before contributing.

License

MIT