Family Chart API Documentation - v0.8.1
    Preparing search index...

    Class Chart

    Main Chart class - The primary class for creating and managing family tree visualizations.

    This is the main entry point for the Family Chart library. Use this class to:

    • Create and configure family tree visualizations
    • Set up data, styling, and interaction options
    • Control tree layout, orientation, and display settings
    • Manage user interactions and updates
    const f3Chart = createChart('#FamilyChart', data)  // returns a Chart instance;
    
    Index

    Constructors

    Properties

    afterUpdate: null | Function
    beforeUpdate: null | Function
    cont: HTMLElement
    editTreeInstance: null | EditTree
    getCard: null | (() => (d: TreeDatum) => void)
    is_card_html: boolean
    linkSpouseText: LinkSpouseText
    personSearch: any
    store: Store
    svg: SVGElement
    transition_time: number

    Methods

    • Calculate the kinships of a person

      Parameters

      • d_id: string

        The id of the person to calculate the kinships of.

      • config: KinshipInfoConfig = {}

        The config for the kinships.

        • show_in_law

          Whether to show in law relations.

      Returns Kinships

      The kinships of the person.

    • Get the kinships data stash with which we can create small family tree with relatives that connects 2 people

      Parameters

      • main_id: string

        The id of the main person.

      • rel_id: string

        The id of the person to get the kinships of.

      Returns void | DatumKinship[]

      The kinships data stash.

    • Get the max depth of a person in the ancestry and progeny

      Parameters

      • d_id: string

        The id of the person to get the max depth of.

      Returns { ancestry: number; progeny: number }

      The max depth of the person in the ancestry and progeny. {ancestry: number, progeny: number}

    • Set the after update of the tree.

      Parameters

      • fn: Function

        The function to call after the update.

      Returns Chart

      The CreateChart instance

    • Set how many generations to show in the ancestry

      Parameters

      • ancestry_depth: number

        The number of generations to show in the ancestry.

      Returns Chart

      The CreateChart instance

    • Set the before update of the tree.

      Parameters

      • fn: Function

        The function to call before the update.

      Returns Chart

      The CreateChart instance

    • Set the card x spacing

      Parameters

      • card_x_spacing: number

        The card x spacing between the cards. Node separation.

      Returns Chart

      The CreateChart instance

    • Set the card y spacing

      Parameters

      • card_y_spacing: number

        The card y spacing between the cards. Level separation.

      Returns Chart

      The CreateChart instance

    • Set whether to show toggable tree branches are duplicated

      Parameters

      • duplicate_branch_toggle: boolean

        Whether to show toggable tree branches are duplicated.

      Returns Chart

      The CreateChart instance

    • Option to set text on spouse links

      Parameters

      • linkSpouseText: LinkSpouseText

        The function to set the text on the spouse links.

        • Example: (sp1, sp2) => getMarriageDate(sp1, sp2)

      Returns Chart

      The CreateChart instance

    • set function that will modify the tree hierarchy. it can be used to delete or add cards in the tree.

      Parameters

      • modifyTreeHierarchy: undefined | ((tree: HN, is_ancestry: boolean) => void)

        function that will modify the tree hierarchy.

      Returns Chart

      The CreateChart instance

    • Set the person dropdown

      Parameters

      • getLabel: Function

        The function to get the label of the person to show in the dropdown.

      • config: { cont?: HTMLElement; onSelect?: (d_id: string) => void; placeholder?: string } = {}

        The config for the person dropdown.

        • Optionalcont?: HTMLElement

          The container to put the dropdown in. Default is the .f3-nav-cont element.

        • OptionalonSelect?: (d_id: string) => void

          The function to call when a person is selected. Default is setting clicked person as main person and updating the tree.

        • Optionalplaceholder?: string

          The placeholder for the search input. Default is 'Search'.

      Returns Chart

      The CreateChart instance

    • Set how many generations to show in the progeny

      Parameters

      • progeny_depth: number

        The number of generations to show in the progeny.

      Returns Chart

      The CreateChart instance

    • Set whether to show the siblings of the main person

      Parameters

      • show_siblings_of_main: boolean

        Whether to show the siblings of the main person.

      Returns Chart

      The CreateChart instance

    • Set whether to show the single parent empty card

      Parameters

      • single_parent_empty_card: boolean

        Whether to show the single parent empty card.

      • label: { label?: string } = {}

        The label to display for the single parent empty card.

      Returns Chart

      The CreateChart instance

    • Set the sort spouses function

      Parameters

      • sortSpousesFunction: SortSpousesFunction

        The sort spouses function.

        • Example: (d, data) => { const spouses = d.data.rels.spouses || [] return spouses.sort((a, b) => { const sp1 = data.find(d0 => d0.id === a) const sp2 = data.find(d0 => d0.id === b) if (!sp1 || !sp2) return 0 return getMarriageDate(d, sp1) - getMarriageDate(d, sp2) }) }) }

      Returns Chart

      The CreateChart instance

    • Set the transition time

      Parameters

      • transition_time: number

        The transition time in milliseconds

      Returns Chart

      The CreateChart instance

    • Update the main person

      Parameters

      • id: string

        New main person id.

      Returns Chart

      The CreateChart instance

    • Update the tree

      Parameters

      • props: ViewProps = ...

        The properties to update the tree with.

        • initial

          Whether to update the tree initially.

        • tree_position

          The position of the tree.

          • 'fit' to fit the tree to the container,
          • 'main_to_middle' to center the tree on the main person,
          • 'inherit' to inherit the position from the previous update.
        • transition_time

          The transition time.

      Returns Chart

      The CreateChart instance