@benportner/js_family_tree
    Preparing search index...

    Class FamilyTree

    Main class for managing, rendering, and interacting with a family tree. Handles data import, layout calculation, rendering, and runtime modifications.

    Index

    Constructors

    • Constructs a new FamilyTree instance.

      Parameters

      • data: FamilyTreeData

        The family tree data object.

      • container: HTMLElement

        The HTML element to render the tree into.

      • Optionalopts: Partial<FamilyTreeOptions>

        Optional configuration for layout, rendering, and styling.

      Returns FamilyTree

    Properties

    The raw family tree data object.

    importer: Importer

    The importer instance used to convert raw data into nodes.

    The layout calculator instance used to assign coordinates to the nodes.

    renderer: Renderer

    The renderer instance used to draw the tree.

    Accessors

    Methods

    • Adds a new link (edge) between two nodes in the family tree data. Optionally re-renders.

      Parameters

      • sourceId: string

        The source node ID.

      • targetId: string

        The target node ID.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Adds a new person to the family tree data and optionally re-renders. Assigns a random ID if data doesn't contain one.

      Parameters

      • data: Person

        The person data to add.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Adds a new union (family) to the family tree data and optionally re-renders. Assigns a random ID if data doesn't contain one.

      Parameters

      • data: Union

        The union data to add.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Removes a link (edge) between two nodes in the family tree data. Optionally re-renders.

      Parameters

      • sourceId: string

        The source node ID.

      • targetId: string

        The target node ID.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Removes a person and all associated links from the family tree data. Optionally re-renders.

      Parameters

      • id: string

        The ID of the person to remove.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Removes a union and all associated links from the family tree data. Optionally re-renders.

      Parameters

      • id: string

        The ID of the union to remove.

      • render: boolean = true

        If true, re-imports and re-renders the tree (default: true).

      Returns void

    • Handles a click event on a node. Expands or collapses the node and re-renders the tree.

      Parameters

      Returns void

    • Re-imports the data and re-renders the tree. Useful after modifying the underlying data (e.g. adding or removing nodes and links).

      Returns void

    • Renders the visible parts of the graph.

      Parameters

      • OptionalclickedNode: LayoutedNode

        The node that was clicked, if any (used for transitions).

      Returns void