Home Reference Source
import BaseTree from 'd3-mitch-tree/js/BaseTree.js'
public class | source

BaseTree

Extends:

events~EventEmitter → BaseTree

Direct Subclass:

BoxedTree, CircleTree

Constructor Summary

Public Constructor
public

constructor(options: object)

Member Summary

Public Members
public
public
Private Members
private
private
private
private
private

_data: *

private
private
private
private

_getId: *

private
private
private
private
private

_links: *

private
private
private
private
private
private
private
private

_root: *

private

_svg: *

private

_theme: *

private
private

_view: *

private
private
private

Method Summary

Public Methods
public

centerNode(nodeDataItem: *): object

Center the view to a D3 tree node.

public

collapse(nodeDataItem: object): object

Collapses the given node data item.

public

Collapses the given node data item, and its children and descendants.

public

expand(nodeDataItem: object): object

Expands the given node data item.

public

expandRecursively(nodeDataItem: object): object

Expands the given node data item, and its children and descendants.

public

focusToNode(idOrNodeDataItem: *): object

Focuses and expands all the way through to a node.

public

Gets the boolean value indicating whether to focus to the clicked node or not.

public

Gets the boolean value indicating whether to pan to a clicked node.

public

Gets the boolean value indicating whether the drag-to-pan pan feature is enabled or not.

public

Gets the boolean value indicating whether the mouse wheel to zoom in/out feature is enabled or not.

public

getChildren(dataItem: object): object[]

Gets the children data items for a given data item.

public

Gets the data items used to render the nodes.

public

Get a single data item given an id.

public

Gets the duration of animations for the tree.

public

Gets the container DOM element.

public

Gets the height of SVG, including the margins.

public

Gets the height of the SVG for the tree diagram.

public

getId(dataItem: object): *

Gets the ID for a given data item.

public

Returns a boolean whether the tree is using flat data or not.

public

Get the array of D3 link data items the D3 tree has generated.

public

Gets the load on demand settings object.

public

Gets the margins for the tree diagram.

public

Gets the maximum zoom scaling.

public

Gets the minimum zoom scaling.

public

getNode(idOrDataItem: * | object): object

Get a single node given an id or a data item.

public

Gets the node depth multiplier that affects the distance between the parent node and the child node.

public

Gets the node settings object.

public

Get the array of D3 node data items the D3 tree has generated.

public

Gets the tree orientation.

public

Gets the D3 selection object for the panning container element.

public

getParentId(dataItem: object): *

Gets the parent ID for a given data item.

public

Gets the root node object.

public

Gets the D3 selection object for the SVG element.

public

Gets the tree theme.

public

Gets the D3 generator object used to generate the tree nodes coordinates.

public

Gets the D3 selection object for the view element.

public

Get the array of visible D3 node data items the D3 tree has generated.

public

Gets the width of SVG, including the margins.

public

Gets the width of the SVG for the tree diagram.

public

Gets the D3 zoom listener used for the panning, zooming and focus features.

public

hideSiblings(nodeDataItem: object): object

Hide the siblings nodes for a given node.

public

Creates and set up the the tree diagram.

public

nodeFocus(nodeDataItem: object): object

Focuses to a node, given a node data item.

public

nodeToggle(nodeDataItem: *): object

Toggles the children visibility for a given node data item.

public

Regenerates the node data.

public

removeSelection(nodeDataItem: object): object

Remove node selections for a given node and it's children.

public

setAllowFocus(newAllowFocus: boolean): object

Sets the boolean value indicating whether to focus to the clicked node or not.

public

setAllowNodeCentering(newAllowNodeCentering: boolean): object

Whether to pan to a clicked node.

public

setAllowPan(newAllowPan: *): object

Sets the boolean value indicating whether the drag-to-pan pan feature is enabled or not.

public

setAllowZoom(newAllowZoom: boolean): object

Sets the boolean value indicating whether the mouse wheel to zoom in/out feature is enabled or not.

public

setChildrenAccessor(newChildrenAccessor: getChildrenCallBack): object

Sets the children accessor callback function, defining how to get the children data items from a given data item.

public

setData(newData: object[]): object

Sets the data items the tree should use to render the nodes.

public

setDuration(newDuration: *): object

Sets the duration of animations for the tree.

public

setElement(newElement: object): object

Sets the container DOM element

public

setHeightWithoutMargins(newHeightWithoutMargin: *): object

Sets the height of the SVG for the tree diagram.

public

setIdAccessor(newIdAccessor: getIdCallBack): object

Sets the ID accessor callback function, defining how to get a unique ID from a given data item.

public

setIsFlatData(newIsFlatData: boolean): *

Sets the is flat data flag.

public

setMargins(newMargins: object): object

Sets the margins for the tree diagram.

public

setMaxScale(newMaxScale: *): object

Sets the maximum zoom scaling.

public

setMinScale(newMinScale: *): object

Sets the minimum zoom scaling.

public

setNodeDepthMultiplier(newNodeDepthMultiplier: number): object

Sets the node depth multiplier value.

public

setOrientation(orientation: string): object

Sets the tree orientation.

public

setParentIdAccessor(newParentIdAccessor: getParentIdCallBack): object

Sets the parent ID accessor callback function, defining how to get the parent ID from a given data item.

public

Sets the tree theme.

public

setWidthWithoutMargins(newWidthWithoutMargin: *): object

Sets the width of the SVG for the tree diagram.

public

update(nodeDataItem: object): object

Updates the tree given a D3 tree node.

public

Updates the dimensions of the SVG.

public

Updates the tree diagram so only the relevant focused node and direct parent hierarchies are shown.

public

Validates the settings to ensure the tree diagram is ready to be generated.

Private Methods
private

_addUnderlyingChildNode(parentNodeDataItem: object, dataItem: object): object

Creates and adds a child D3 tree node to a given parent D3 tree node.

private

_createNode(parentNodeDataItem: object, dataItem: object): object

Creates a child D3 tree node.

private

Gets the path generator used to render the links between the nodes.

private

Called when updating dimensions when node settings is configured to be 'nodesize'.

private

_linkEnter(source: *, linkEnter: *, links: *, linkPathGenerator: *): object

Defines how to create the links for newly added data objects.

private

_linkExit(source: object, linkExit: *, linkExitTransition: *, links: *, linkPathGenerator: *): object

Defines how to remove the links for the removed data objects.

private

_linkUpdate(source: *, linkUpdate: *, linkUpdateTransition: *, links: *, linkPathGenerator: *): object

Defines how to update the links for the data objects.

private

_nodeEnter(nodeEnter: *, nodes: *): object

Defines how to create the nodes for newly added data objects.

private

_nodeExit(nodeExit: *, nodeExitTransition: *, nodes: *): object

Defines how to remove the nodes for the removed data objects.

private

_nodeUpdate(nodeUpdate: *, nodeUpdateTransition: *, nodes: *): object

Defines how to update the nodes for the data objects.

private

_onNodeClick(nodeDataItem: object, index: number, arr: object[]): boolean

Triggers the nodeClick event when a D3 node is clicked on, and proceeds to focus/expand/collapse the node.

private

Populates the node's children to a hidden property.

private

_processLoadedDataForNodeFocus(nodeDataItem: object, result: object[]): object

Process the loaded data from AJAX resulting from a node expand.

private

Process the loaded data from AJAX resulting from a node toggle.

private

_updateLinks(nodeDataItem: object, links: object[]): object

Updates the tree node links given a D3 tree node.

private

_updateNodes(nodeDataItem: object, nodes: object[]): object

Updates the tree nodes given a D3 tree node.

Public Constructors

public constructor(options: object) source

Params:

NameTypeAttributeDescription
options object

The options object.

options.theme string
  • optional
  • default: default

The theme of the tree.

options.orientation string
  • optional
  • default: leftToRight

The orientation of the tree.

options.allowPan boolean
  • optional
  • default: true

Enables/disables the mouse drag to pan feature.

options.allowZoom boolean
  • optional
  • default: true

Enables/disables the mouse wheel to zoom feature.

options.allowFocus boolean
  • optional
  • default: true

If true, clicking on a node would focus to the node, hiding all irrelevant nodes that's not a parent, ancestor, or sibling.

options.allowNodeCentering boolean
  • optional
  • default: true

If true, clicking on a node would pan to the node.

options.minScale number
  • optional
  • default: 1

Minimum zoom scaling.

options.maxScale number
  • optional
  • default: 2

Maximum zoom scaling.

options.nodeDepthMultiplier number
  • optional
  • default: 300

The distance between the parent and child nodes.

options.isFlatData boolean
  • optional
  • default: false

Indicates whether the passed data was a flat array of objects. If true, you must specify the getParentId option.

options.getId getIdCallBack
options.getParentId getParentIdCallBack
  • optional
options.getChildren getChildrenCallBack
  • optional
options.widthWithoutMargins number
  • optional
  • default: 960

The width of the tree, not including the margins.

options.heightWithoutMargins number
  • optional
  • default: 800

The height of the tree, not including the margins.

options.margins object
  • optional

Object specifying the margins of the tree diagram.

options.margins.top number
  • optional

The top margin for the tree diagram.

options.margins.right number
  • optional

The right margin for the tree diagram.

options.margins.bottom number
  • optional

The bottom margin for the tree diagram.

options.margins.left number
  • optional

The left margin for the tree diagram.

options.duration number
  • optional

Integer in milliseconds determining the duration of the animations for the tree.

options.loadOnDemandSettings LoadOnDemandSettings
  • optional

Object specifying the load-on-demand settings.

options.nodeSettings NodeSettings
  • optional

Object specifying the node settings for the tree.

Public Members

public loadOnDemandSettings: * source

public nodeSettings: * source

Private Members

private _allowFocus: * source

private _allowNodeCentering: * source

private _allowPan: * source

private _allowZoom: * source

private _data: * source

private _duration: * source

private _element: * source

private _getChildren: * source

private _getId: * source

private _getParentId: * source

private _heightWithoutMargin: * source

private _isFlatData: * source

private _linkPathGenerator: * source

private _margins: * source

private _maxScale: * source

private _minScale: * source

private _nodeDepthMultiplier: * source

private _nodes: undefined[] source

private _orientation: * source

private _panningContainer: * source

private _root: * source

private _svg: * source

private _theme: * source

private _treeGenerator: * source

private _view: * source

private _visibleNodes: * source

private _widthWithoutMargin: * source

private _zoomListener: * source

Public Methods

public centerNode(nodeDataItem: *): object source

Center the view to a D3 tree node.

Params:

NameTypeAttributeDescription
nodeDataItem *

The D3 node data item to focus on.

Return:

object

The tree object.

public collapse(nodeDataItem: object): object source

Collapses the given node data item.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to collapse.

Return:

object

The tree object.

public collapseRecursively(nodeDataItem: object): object source

Collapses the given node data item, and its children and descendants.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to collapse.

Return:

object

The tree object.

public expand(nodeDataItem: object): object source

Expands the given node data item.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to expand.

Return:

object

The tree object.

public expandRecursively(nodeDataItem: object): object source

Expands the given node data item, and its children and descendants.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to expand.

Return:

object

The tree object.

public focusToNode(idOrNodeDataItem: *): object source

Focuses and expands all the way through to a node.

Params:

NameTypeAttributeDescription
idOrNodeDataItem *

The id of the node to focus, or the node data item object.

Return:

object

The tree object.

public getAllowFocus(): boolean source

Gets the boolean value indicating whether to focus to the clicked node or not. Focusing on a node would hide all irrelevant nodes that's not a parent, sibling or ancestor of the clicked node.

Return:

boolean

Whether to focus to the clicked node.

public getAllowNodeCentering(): boolean source

Gets the boolean value indicating whether to pan to a clicked node.

Return:

boolean

Whether to pan to the clicked node.

public getAllowPan(): boolean source

Gets the boolean value indicating whether the drag-to-pan pan feature is enabled or not.

Return:

boolean

Whether panning is enabled or not.

public getAllowZoom(): boolean source

Gets the boolean value indicating whether the mouse wheel to zoom in/out feature is enabled or not.

Return:

boolean

Whether zooming is enabled or not.

public getChildren(dataItem: object): object[] source

Gets the children data items for a given data item.

Params:

NameTypeAttributeDescription
dataItem object

The data item to get the children data items from.

Return:

object[]

The array of child data items.

public getData(): object[] source

Gets the data items used to render the nodes.

Return:

object[]

The array of data items the tree uses.

public getDataItem(id: *): object source

Get a single data item given an id.

Params:

NameTypeAttributeDescription
id *

The ID to retrieve the data item with.

Return:

object

The data item with the given ID.

public getDuration(): number source

Gets the duration of animations for the tree.

Return:

number

The animation duration in milliseconds.

public getElement(): object source

Gets the container DOM element.

Return:

object

The container DOM element.

public getHeight(): number source

Gets the height of SVG, including the margins.

Return:

number

The height of the SVG.

public getHeightWithoutMargins(): number source

Gets the height of the SVG for the tree diagram. Does not include the margins.

Return:

number

The height (not including the margins) of the SVG for the tree diagram.

public getId(dataItem: object): * source

Gets the ID for a given data item.

Params:

NameTypeAttributeDescription
dataItem object

The data item to get the ID from.

Return:

*

The ID for the given data item.

public getIsFlatData(): boolean source

Returns a boolean whether the tree is using flat data or not.

Return:

boolean

Whether the tree is using flat data or not.

Get the array of D3 link data items the D3 tree has generated.

Return:

object[]

Array of D3 link data items.

public getLoadOnDemandSettings(): LoadOnDemandSettings source

Gets the load on demand settings object.

Return:

LoadOnDemandSettings

The load on demand settings.

public getMargins(): object source

Gets the margins for the tree diagram.

Return:

object

The margins object.

public getMaxScale(): number source

Gets the maximum zoom scaling.

Return:

number

Maximum zoom scale value.

public getMinScale(): number source

Gets the minimum zoom scaling.

Return:

number

The minimum zoom scale value.

public getNode(idOrDataItem: * | object): object source

Get a single node given an id or a data item.

Params:

NameTypeAttributeDescription
idOrDataItem * | object

The ID or data item to retrieve the D3 tree node data item with.

Return:

object

D3 tree node data item.

public getNodeDepthMultiplier(): number source

Gets the node depth multiplier that affects the distance between the parent node and the child node.

Return:

number

The node depth multiplier value

public getNodeSettings(): NodeSettings source

Gets the node settings object.

Return:

NodeSettings

The node settings.

public getNodes(): object[] source

Get the array of D3 node data items the D3 tree has generated.

Return:

object[]

Array of D3 node data items.

public getOrientation(): string source

Gets the tree orientation.

Return:

string

The orientation the tree is using.

public getPanningContainer(): object source

Gets the D3 selection object for the panning container element.

Return:

object

D3 selection object for the panning container element.

public getParentId(dataItem: object): * source

Gets the parent ID for a given data item.

Params:

NameTypeAttributeDescription
dataItem object

The data item to get the parent ID from.

Return:

*

The parent ID for the given data item.

public getRoot(): object source

Gets the root node object.

Return:

object

The root D3 tree node object.

public getSvg(): object source

Gets the D3 selection object for the SVG element.

Return:

object

Returns the D3 selection object.

public getTheme(): string source

Gets the tree theme.

Return:

string

The theme the tree is using.

public getTreeGenerator(): function source

Gets the D3 generator object used to generate the tree nodes coordinates.

Return:

function

D3 tree generator object.

public getView(): object source

Gets the D3 selection object for the view element.

Return:

object

D3 selection object for the view element.

public getVisibleNodes(): object[] source

Get the array of visible D3 node data items the D3 tree has generated.

Return:

object[]

Array of D3 node data items.

public getWidth(): number source

Gets the width of SVG, including the margins.

Return:

number

The width of the SVG.

public getWidthWithoutMargins(): number source

Gets the width of the SVG for the tree diagram. Does not include the margins.

Return:

number

The width (not including the margins) of the SVG for the tree diagram.

public getZoomListener(): function source

Gets the D3 zoom listener used for the panning, zooming and focus features.

Return:

function

The D3 zoom listener

public hideSiblings(nodeDataItem: object): object source

Hide the siblings nodes for a given node.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node to hide siblings for.

Return:

object

The tree object.

public initialize(): object source

Creates and set up the the tree diagram.

Return:

object

The tree object.

public nodeFocus(nodeDataItem: object): object source

Focuses to a node, given a node data item.

Params:

NameTypeAttributeDescription
nodeDataItem object

The node being focused on.

Return:

object

The tree object.

public nodeToggle(nodeDataItem: *): object source

Toggles the children visibility for a given node data item.

Params:

NameTypeAttributeDescription
nodeDataItem *

D3 Node data item.

Return:

object

The tree object.

public regenerateNodeData(): object source

Regenerates the node data.

Return:

object

The tree object.

public removeSelection(nodeDataItem: object): object source

Remove node selections for a given node and it's children.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to remove selection from.

Return:

object

The tree object.

public setAllowFocus(newAllowFocus: boolean): object source

Sets the boolean value indicating whether to focus to the clicked node or not. Focusing on a node would hide all irrelevant nodes that's not a parent, sibling or ancestor of the clicked node.

Params:

NameTypeAttributeDescription
newAllowFocus boolean

Whether to pan to the clicked node.

Return:

object

The tree object.

public setAllowNodeCentering(newAllowNodeCentering: boolean): object source

Whether to pan to a clicked node.

Params:

NameTypeAttributeDescription
newAllowNodeCentering boolean

Whether to pan to the clicked node.

Return:

object

The tree object.

public setAllowPan(newAllowPan: *): object source

Sets the boolean value indicating whether the drag-to-pan pan feature is enabled or not.

Params:

NameTypeAttributeDescription
newAllowPan *

Whether panning is enabled or not.

Return:

object

The tree object.

public setAllowZoom(newAllowZoom: boolean): object source

Sets the boolean value indicating whether the mouse wheel to zoom in/out feature is enabled or not.

Params:

NameTypeAttributeDescription
newAllowZoom boolean

Whether zooming is enabled or not.

Return:

object

The tree object.

public setChildrenAccessor(newChildrenAccessor: getChildrenCallBack): object source

Sets the children accessor callback function, defining how to get the children data items from a given data item.

Params:

NameTypeAttributeDescription
newChildrenAccessor getChildrenCallBack

Callback function to get the children for a given data item.

Return:

object

The tree object.

public setData(newData: object[]): object source

Sets the data items the tree should use to render the nodes.

Params:

NameTypeAttributeDescription
newData object[]

The new set of data items.

Return:

object

The tree object.

public setDuration(newDuration: *): object source

Sets the duration of animations for the tree.

Params:

NameTypeAttributeDescription
newDuration *

The animation duration in milliseconds.

Return:

object

The tree object.

public setElement(newElement: object): object source

Sets the container DOM element

Params:

NameTypeAttributeDescription
newElement object

The container DOM element.

Return:

object

The tree object.

public setHeightWithoutMargins(newHeightWithoutMargin: *): object source

Sets the height of the SVG for the tree diagram.

Params:

NameTypeAttributeDescription
newHeightWithoutMargin *

The height of SVG for the tree diagram.

Return:

object

The tree object.

public setIdAccessor(newIdAccessor: getIdCallBack): object source

Sets the ID accessor callback function, defining how to get a unique ID from a given data item.

Params:

NameTypeAttributeDescription
newIdAccessor getIdCallBack

Callback function to get the ID for a given data item.

Return:

object

The tree object.

public setIsFlatData(newIsFlatData: boolean): * source

Sets the is flat data flag. If set to true, you must specify the getParentId option.

Params:

NameTypeAttributeDescription
newIsFlatData boolean

Whether the tree is using flat data or not.

Return:

*

public setMargins(newMargins: object): object source

Sets the margins for the tree diagram.

Params:

NameTypeAttributeDescription
newMargins object

The margin object.

newMargins.top number

The margin top for the tree diagram.

newMargins.right number

The margin right for the tree diagram.

newMargins.bottom number

The margin bottom for the tree diagram.

newMargins.left number

The margin left for the tree diagram.

Return:

object

The tree object.

public setMaxScale(newMaxScale: *): object source

Sets the maximum zoom scaling.

Params:

NameTypeAttributeDescription
newMaxScale *

The maximum zoom scale value.

Return:

object

The tree object.

public setMinScale(newMinScale: *): object source

Sets the minimum zoom scaling.

Params:

NameTypeAttributeDescription
newMinScale *

The minimum zoom scale value.

Return:

object

The tree object.

public setNodeDepthMultiplier(newNodeDepthMultiplier: number): object source

Sets the node depth multiplier value.

Params:

NameTypeAttributeDescription
newNodeDepthMultiplier number

The value that affects the distance between the parent node and the child node.

Return:

object

The tree object.

public setOrientation(orientation: string): object source

Sets the tree orientation.

Params:

NameTypeAttributeDescription
orientation string

The orientation to set the tree to.

Return:

object

The tree object.

public setParentIdAccessor(newParentIdAccessor: getParentIdCallBack): object source

Sets the parent ID accessor callback function, defining how to get the parent ID from a given data item.

Params:

NameTypeAttributeDescription
newParentIdAccessor getParentIdCallBack

Callback function to get the parent id for a given data item.

Return:

object

The tree object.

public setTheme(theme: string): object source

Sets the tree theme.

Params:

NameTypeAttributeDescription
theme string

The theme to set the tree to.

Return:

object

The tree object.

public setWidthWithoutMargins(newWidthWithoutMargin: *): object source

Sets the width of the SVG for the tree diagram.

Params:

NameTypeAttributeDescription
newWidthWithoutMargin *

The width of SVG for the tree diagram.

Return:

object

The tree object.

public update(nodeDataItem: object): object source

Updates the tree given a D3 tree node.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item.

Return:

object

The tree object.

public updateDimensions(): object source

Updates the dimensions of the SVG.

Return:

object

The tree object.

public updateTreeWithFocusOnNode(nodeDataItem: object): object source

Updates the tree diagram so only the relevant focused node and direct parent hierarchies are shown.

Params:

NameTypeAttributeDescription
nodeDataItem object

D3 Node data item.

Return:

object

The tree object.

public validateSettings(): object source

Validates the settings to ensure the tree diagram is ready to be generated.

Return:

object

The tree object.

Private Methods

private _addUnderlyingChildNode(parentNodeDataItem: object, dataItem: object): object source

Creates and adds a child D3 tree node to a given parent D3 tree node.

Params:

NameTypeAttributeDescription
parentNodeDataItem object

The parent D3 tree node data item.

dataItem object

The data item.

Return:

object

The newly created and added D3 node;

private _createNode(parentNodeDataItem: object, dataItem: object): object source

Creates a child D3 tree node.

Params:

NameTypeAttributeDescription
parentNodeDataItem object

The parent D3 tree node data item.

dataItem object

The data item.

Return:

object

The newly created D3 node;

private _getLinkPathGenerator(): function source

Gets the path generator used to render the links between the nodes.

Return:

function

The callback function that generates the SVG path coordinates for the links, given a coordinates object.

private _getNodeSize(): number[] source

Called when updating dimensions when node settings is configured to be 'nodesize'.

Return:

number[]

An array with two values, representing the height and width of the node respectively.

private _linkEnter(source: *, linkEnter: *, links: *, linkPathGenerator: *): object source

Defines how to create the links for newly added data objects.

Params:

NameTypeAttributeDescription
source *

The original data object that the links are being drawn for.

linkEnter *

The D3 Enter selection of links.

links *
linkPathGenerator *

Return:

object

The tree object.

private _linkExit(source: object, linkExit: *, linkExitTransition: *, links: *, linkPathGenerator: *): object source

Defines how to remove the links for the removed data objects.

Params:

NameTypeAttributeDescription
source object

The original data object that the links are being drawn for.

linkExit *

The D3 Exit selection of links.

linkExitTransition *

The D3 transition object for the D3 Update selection of links.

links *
linkPathGenerator *

The link path generator function.

Return:

object

The tree object.

private _linkUpdate(source: *, linkUpdate: *, linkUpdateTransition: *, links: *, linkPathGenerator: *): object source

Defines how to update the links for the data objects.

Params:

NameTypeAttributeDescription
source *

The original data object that the links are being drawn for.

linkUpdate *

The D3 Update selection of links.

linkUpdateTransition *

The D3 transition object for the D3 Update selection of links.

links *
linkPathGenerator *

The link path generator function.

Return:

object

The tree object.

private _nodeEnter(nodeEnter: *, nodes: *): object source

Defines how to create the nodes for newly added data objects.

Params:

NameTypeAttributeDescription
nodeEnter *

The D3 Enter selection of nodes.

nodes *

Return:

object

The tree object.

private _nodeExit(nodeExit: *, nodeExitTransition: *, nodes: *): object source

Defines how to remove the nodes for the removed data objects.

Params:

NameTypeAttributeDescription
nodeExit *

The D3 Exit selection of nodes.

nodeExitTransition *

The D3 transition object for the D3 Exit selection of nodes.

nodes *

Return:

object

The tree object.

private _nodeUpdate(nodeUpdate: *, nodeUpdateTransition: *, nodes: *): object source

Defines how to update the nodes for the data objects.

Params:

NameTypeAttributeDescription
nodeUpdate *

The D3 Update selection of nodes.

nodeUpdateTransition *

The D3 transition object for the D3 Update selection of nodes.

nodes *

Return:

object

The tree object.

private _onNodeClick(nodeDataItem: object, index: number, arr: object[]): boolean source

Triggers the nodeClick event when a D3 node is clicked on, and proceeds to focus/expand/collapse the node.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item that was clicked.

index number

The index of the D3 node being clicked in the array of siblings.

arr object[]

Array of siblings D3 node, inclusive of the clicked node data item itself.

Return:

boolean

True meaning it successfully focused/expanded/collapsed a node. False otherwise.

Emit:

nodeClick

Emit node click event.

private _populateUnderlyingChildren(nodeDataItem: object): object source

Populates the node's children to a hidden property.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to collapse.

Return:

object

The tree object.

private _processLoadedDataForNodeFocus(nodeDataItem: object, result: object[]): object source

Process the loaded data from AJAX resulting from a node expand.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item being expanded.

result object[]

The children data items to process.

Return:

object

The tree object.

private _processLoadedDataForNodeToggle(nodeDataItem: object, result: object[]): object source

Process the loaded data from AJAX resulting from a node toggle.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item.

result object[]

Array of sibling node data items, inclusive the node being toggled.

Return:

object

The tree object.

Updates the tree node links given a D3 tree node.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item.

links object[]

Array of D3 link data items.

Return:

object

The tree object.

private _updateNodes(nodeDataItem: object, nodes: object[]): object source

Updates the tree nodes given a D3 tree node.

Params:

NameTypeAttributeDescription
nodeDataItem object

The D3 node data item to update.

nodes object[]

Array of D3 node data items.

Return:

object

The tree object.