Table of Contents
- TidyTree
- Parameters
- setData
- setTree
- draw
- redraw
- recenter
- setLayout
- setColorOptions
- setMode
- setType
- setRotation
- setHStretch
- setVStretch
- setAnimation
- setBranchNodes
- eachBranchNode
- setBranchLabels
- eachBranchLabel
- setBranchDistances
- eachBranchDistance
- setLeafNodes
- eachLeafNode
- setEquidistantLeaves
- setLeafLabels
- eachLeafLabel
- setRuler
- getNodeGUIDs
- search
- on
- off
- trigger
- destroy
- validLayouts
- validTypes
- validModes
- validNodeColorModes
- validBranchColorModes
- circularPoint
- findNodeColor
- findBranchColor
- getAllLeaves
TidyTree
This class function creates a TidyTree object.
Parameters
dataoptionsObject A Javascript object containing options to set up the treeeventsnewickString A valid newick string
setData
Update the TidyTree’s underlying data structure There are two contexts in which you should call this: 1. You wish to replace the tree with a completely different tree, given by a different newick string 2. Your underlying tree data has changed (e.g. the tree has been re-rooted)
Parameters
dataObject A patristic.Branch object
Returns Object the TidyTree object
setTree
Update the TidyTree’s underlying data structure There are two contexts in which you should call this: 1. You wish to replace the tree with a completely different tree, given by a different newick string 2. Your underlying tree data has changed (e.g. the tree has been re-rooted)
Parameters
newickString A valid newick string
Returns Object the TidyTree object
draw
Draws a Phylogenetic on the element referred to by selector
Parameters
selectorString A CSS selector
Returns TidyTree the TidyTree object
redraw
Redraws the links and relocates the nodes accordingly
Returns TidyTree The TidyTree Object
recenter
Recenters the tree in the center of the view
Returns TidyTree The TidyTree object
setLayout
Set the TidyTree’s layout
Parameters
newLayoutString The new layout
Returns TidyTree The TidyTree Object
setColorOptions
Set the TidyTree’s colorOptions
Parameters
newColorOptionsObject The new colorOptions
Returns TidyTree The TidyTree Object
setMode
Set the TidyTree’s mode
Parameters
newModeString The new mode
Returns TidyTree The TidyTree object
setType
Set the TidyTree’s type
Parameters
newTypeBoolean The new type
Returns TidyTree the TidyTree object
setRotation
Set the TidyTree’s rotation
Parameters
degreesNumber The new number of degrees by which to rotate the tree
Returns TidyTree the TidyTree object
setHStretch
Set the TidyTree’s Horizontal Stretch
Parameters
proportionNumber The new proportion by which to stretch the tree
Returns TidyTree the TidyTree object
setVStretch
Set the TidyTree’s Vertical Stretch
Parameters
proportionNumber The new proportion by which to stretch the tree
Returns TidyTree the TidyTree object
setAnimation
Set the TidyTree’s animation time. Note that this does not trigger a redraw.
Parameters
timenumber The desired duration of an animation, in ms. Set to 0 to turn animations off completely.
Returns TidyTree The TidyTree object
setBranchNodes
Shows or hides the Branch Nodes
Parameters
showBoolean Should Branch nodes be shown?
Returns TidyTree the TidyTree object
eachBranchNode
Restyles Leaf Nodes
Parameters
stylerFunction A function that restyles each node.stylerreceives a reference to the DOM node to be styled, and an associated data object.
Returns TidyTree the TidyTree Object
setBranchLabels
Set the TidyTree’s branchLabels
Parameters
showBoolean Should the TidyTree show branchLabels?
Returns TidyTree the TidyTree Object
eachBranchLabel
Restyles Branch Label
Parameters
stylerFunction A function that restyles each node.stylerreceives a reference to the DOM node to be styled, and an associated data object.
Returns TidyTree the TidyTree Object
setBranchDistances
Shows or hides the TidyTree’s branch labels
Parameters
showBoolean Should the TidyTree show branch distances?
Returns TidyTree The TidyTree Object
eachBranchDistance
Restyles Branch Distances
Parameters
stylerFunction A function that restyles each node.stylerreceives a reference to the DOM node to be styled, and an associated data object.
Returns TidyTree the TidyTree Object
setLeafNodes
Shows or Hides the Leaf Nodes
Parameters
showBoolean Should leaf nodes be visible?
Returns TidyTree The TidyTree Object
eachLeafNode
Restyles Leaf Nodes
Parameters
stylerFunction A function that restyles each node.stylerreceives a reference to the DOM node to be styled, and an associated data object.
Returns TidyTree the TidyTree Object
setEquidistantLeaves
Set the TidyTree’s leaves to be equidistant
Parameters
isEquidistant
setLeafLabels
Shows or Hides the TidyTree’s Leaf Labels
Parameters
showBoolean Should the TidyTree show leafLabels?
Returns TidyTree the TidyTree Object
eachLeafLabel
Restyles Leaf Labels
Parameters
stylerFunction A function that restyles each node.stylerreceives a reference to the DOM node to be styled, and an associated data object.
Returns TidyTree the TidyTree Object
setRuler
Shows or hides the TidyTree’s branch labels
Parameters
showBoolean Should the TidyTree show branchLabels?
Returns TidyTree The TidyTree Object
getNodeGUIDs
Retrieves the GUIDs of the nodes in the TidyTree instance.
Parameters
leavesOnlyboolean Whether to retrieve GUIDs only for leaf nodes.predicatefunction A function that returns true if the node should be included
Returns Array An array of GUIDs of the nodes.
search
Searches the tree, returns Search Results
Parameters
testFunction A function which takes a Branch and returns a Truthy or Falsy value.
Returns Array The array of results
on
Attaches a new event listener Please note that this is not yet functioning.
Parameters
eventsString A space-delimited list of event namescallbackFunction The function to run when one of theeventsoccurs.
Returns TidyTree The TidyTree on which this method was called.
off
Removes all event listeners from the given events
Parameters
eventsString A space-delimited list of event names
Returns TidyTree The TidyTree on which this method was called.
trigger
Forces the tree to respond as though an event has occurred
Parameters
eventsString space-delimited list of names of events to trigger.argsSpread Any arguments which should be passed to the event handler(s).
Returns any The output of the callback run on event
destroy
Destroys the TidyTree
Returns undefined
validLayouts
The available layouts for rendering trees.
Type: Array
validTypes
The available types for rendering branches.
Type: Array
validModes
The available modes for rendering branches.
Type: Array
validNodeColorModes
The available color modes for rendering nodes.
Type: Array
validBranchColorModes
The available color modes for rendering branches.
Type: Array
circularPoint
Calculate the coordinates of a point transformed onto a circle.
Parameters
xnumber The x-coordinate of the center of the point.ynumber The y-coordinate of the center of the point.
Returns Array<number> The new x and y coordinates of the point on the circle.
findNodeColor
Finds the color of a given node based on the color options provided.
Parameters
nodeObject The node for which to find the color.colorOptionsObject The color options object containing the color mode, leavesOnly, predicate, default color, and highlight color.
Returns string The color of the node.
findBranchColor
Find the color of a given link based on the provided color options.
Parameters
linkstring The link for which to find the color.colorOptionsobject The options for different link colors.
Returns string The color of the link.
getAllLeaves
Returns an array of all the child leaf nodes of the given node in a tree.
Parameters
nodeObject A node of the tree.includeSelfboolean Whether to include the given node itself as a leaf node. Defaults to false.
Returns Array An array of leaf nodes.