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
data
options
Object A Javascript object containing options to set up the treeevents
newick
String 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
data
Object 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
newick
String A valid newick string
Returns Object the TidyTree object
draw
Draws a Phylogenetic on the element referred to by selector
Parameters
selector
String 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
newLayout
String The new layout
Returns TidyTree The TidyTree Object
setColorOptions
Set the TidyTree’s colorOptions
Parameters
newColorOptions
Object The new colorOptions
Returns TidyTree The TidyTree Object
setMode
Set the TidyTree’s mode
Parameters
newMode
String The new mode
Returns TidyTree The TidyTree object
setType
Set the TidyTree’s type
Parameters
newType
Boolean The new type
Returns TidyTree the TidyTree object
setRotation
Set the TidyTree’s rotation
Parameters
degrees
Number The new number of degrees by which to rotate the tree
Returns TidyTree the TidyTree object
setHStretch
Set the TidyTree’s Horizontal Stretch
Parameters
proportion
Number The new proportion by which to stretch the tree
Returns TidyTree the TidyTree object
setVStretch
Set the TidyTree’s Vertical Stretch
Parameters
proportion
Number 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
time
number 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
show
Boolean Should Branch nodes be shown?
Returns TidyTree the TidyTree object
eachBranchNode
Restyles Leaf Nodes
Parameters
styler
Function A function that restyles each node.styler
receives 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
show
Boolean Should the TidyTree show branchLabels?
Returns TidyTree the TidyTree Object
eachBranchLabel
Restyles Branch Label
Parameters
styler
Function A function that restyles each node.styler
receives 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
show
Boolean Should the TidyTree show branch distances?
Returns TidyTree The TidyTree Object
eachBranchDistance
Restyles Branch Distances
Parameters
styler
Function A function that restyles each node.styler
receives 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
show
Boolean Should leaf nodes be visible?
Returns TidyTree The TidyTree Object
eachLeafNode
Restyles Leaf Nodes
Parameters
styler
Function A function that restyles each node.styler
receives 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
show
Boolean Should the TidyTree show leafLabels?
Returns TidyTree the TidyTree Object
eachLeafLabel
Restyles Leaf Labels
Parameters
styler
Function A function that restyles each node.styler
receives 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
show
Boolean Should the TidyTree show branchLabels?
Returns TidyTree The TidyTree Object
getNodeGUIDs
Retrieves the GUIDs of the nodes in the TidyTree instance.
Parameters
leavesOnly
boolean Whether to retrieve GUIDs only for leaf nodes.predicate
function 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
test
Function 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
events
String A space-delimited list of event namescallback
Function The function to run when one of theevents
occurs.
Returns TidyTree The TidyTree on which this method was called.
off
Removes all event listeners from the given events
Parameters
events
String 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
events
String space-delimited list of names of events to trigger.args
Spread 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
x
number The x-coordinate of the center of the point.y
number 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
node
Object The node for which to find the color.colorOptions
Object The color options object containing the color mode, node list, 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
link
string The link for which to find the color.colorOptions
object 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
node
Object A node of the tree.includeSelf
boolean Whether to include the given node itself as a leaf node. Defaults to false.
Returns Array An array of leaf nodes.