Options
All
  • Public
  • Public/Protected
  • All
Menu

A template object.

let familyTree = new FamilyTree2(document.getElementById('tree'));

let template = familyTree.template;

Hierarchy

  • Template

Index

Properties

fill: string

Nodes color.

template.fill = '#F57C00';
template.nodes.focus.fill = '#039BE5';
height: number

Nodes height.

template.height = 200;
template.nodes.focus.height = 250;
layout: string

Template Link

let link = template.link;
nodes: { child: ShapeTemplate; childInLaw: ShapeTemplate; focus: ShapeTemplate; parent: ShapeTemplate; parentInLaw: ShapeTemplate; parentSibling: ShapeTemplate; pibling: ShapeTemplate; sibling: ShapeTemplate; spouse: ShapeTemplate; stepParent: ShapeTemplate }

Relationship node types

let nodes = template.nodes;

Type declaration

  • child: ShapeTemplate
  • childInLaw: ShapeTemplate
  • focus: ShapeTemplate
  • parent: ShapeTemplate
  • parentInLaw: ShapeTemplate
  • parentSibling: ShapeTemplate
  • pibling: ShapeTemplate
  • sibling: ShapeTemplate
  • spouse: ShapeTemplate
  • stepParent: ShapeTemplate
separations: Separations

Separations between nodes

let separations = template.separations;
stroke: number

Nodes border color.

template.stroke = '#FFCA28';
template.nodes.focus.stroke = '#F57C00';
strokeWidth: number

Nodes border width.

template.strokeWidth = 5;
template.nodes.focus.strokeWidth = 7;
width: number

Nodes width.

template.width = 300;
template.nodes.focus.width = 350;

Methods

  • html(node: Node): void
  • Defines he node HTML.

    template.html = function(node) {
    return `<div data-field="address">${node.familyMember.name}</div>`;
    };

    Parameters

    Returns void

  • insertSvg(node: Node): string
  • Adds SVG to the node.

    template.insertSvg = function(node){
    return `<text text-anchor="end" x="${node.width}" y="${node.height + 16}">
    ${node.relationshipType}
    </text>`
    };

    Parameters

    Returns string

  • svg(node: Node): string
  • Defines he node SVG.

    template.svg = function(node){
    return `<rect rx="20" ry="20" x="0" y="0"
    width="${node.width}" height="${node.height}"
    style=" stroke:${node.stroke}; fill: ${node.fill}; stroke-width: ${node.strokeWidth};">
    </rect>`;
    };

    Parameters

    Returns string

  • svgButton(node: Node, x: number, y: number, text: string, icon: string, type: string, color: string, title: string): string
  • Defines the SVG buttons.

    familyTree.template.svgButton = function (node, x, y, text, icon, type, color, title) {
    let radius = 12;

    if (type == 'edit' || type == 'camera') {
    return '';
    }

    if (type == 'focus') {
    radius = 16;
    x = 0;
    y = node.height / 2;
    icon = `
    <svg xmlns="http://www.w3.org/2000/svg"
    width="24" height="24" x="4" y="4"
    viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2">
    <circle cx="11" cy="11" r="8"></circle>
    <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
    </svg>`;
    }

    return `
    <g transform="translate(${x - radius}, ${y - radius})"
    data-button="${type}" class="bft2-button">
    <circle cx="${radius}" cy="${radius}" r="${radius}"
    style="fill:${color}; stroke-width:0;" />
    ${icon}
    ${text}
    </g>`;
    }

    Parameters

    • node: Node
    • x: number
    • y: number
    • text: string
    • icon: string
    • type: string
    • color: string
    • title: string

    Returns string

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Static method

Settings

Theme

Generated using TypeDoc