Members
branchLength :number⚓
The length of the branch.
centerx :number⚓
The center of the end of the node on the x axis.
centery :number⚓
The center of the end of the node on the y axis.
children :Array.<Branch>⚓
The branches that stem from this branch.
collapsed :boolean⚓
True if the node has been collapsed.
colour :string⚓
Custom colour for branch, initialised as null to use tree-level default.
data :object⚓
Holds custom data for this node.
highlighted :boolean⚓
This node's highlight status.
hovered :boolean⚓
Whether the user is hovering over the node.
id :string⚓
This node's unique ID.
label :string⚓
The text label for this node.
leaf :boolean⚓
If true, this node has no children.
maxChildAngle :number⚓
The angle that the last child of this brach 'splays' at, used for
circular trees.
minChildAngle :number⚓
The angle that the last child of this brach 'splays' at, used for
circular trees.
nodeShape :string⚓
What kind of teminal should be drawn on this node.
parent :Branch⚓
The parent branch of this branch.
radius :number⚓
The relative size of the terminal of this node.
selected :boolean⚓
True if this branch is currently selected.
startx :number⚓
The x position of the start of the branch.
starty :number⚓
The y position of the start of the branch.
totalBranchLength :number⚓
The length from the root of the tree to the tip of this branch.
tree :Tree⚓
The tree object that this branch is part of.
pruned :boolean⚓
If true, this branch is not rendered.
labelStyle :object⚓
Allows label to be individually styled.
Properties:
Name | Type | Description |
---|---|---|
colour |
string | |
textSize |
number | |
font |
string | |
format |
string | e.g. bold, italic |
interactive :boolean⚓
If false, branch does not respond to mouse events.
leafStyle :object⚓
Defines leaf style for this branch.
Properties:
Name | Type |
---|---|
lineWidth |
number |
strokeStyle |
string |
fillStyle |
string |
Example
branch.leafStyle = {
lineWidth: 2,
strokeStyle: '#ff0000',
fillStyle: 'blue'
};
minx :number⚓
Minimum x coordintate.
miny :number⚓
Minimum y coordintate.
maxx :number⚓
Maximum x coordintate.
maxy :number⚓
Maximum y coordintate.
isHighlighted :boolean⚓
True if the branch is highlighted or hovered.
canvas :CanvasRenderingContext2D⚓
The canvas drawing context of the parent tree.
(static) lastId :number⚓
Static counter for generated ids.
angle :number⚓
The branch's angle clockwise from horizontal in radians (used paricularly
for circular and radial trees).
Methods
generateId() → {string}⚓
For branches without a label.
Returns:
new ID
- Type
- string
clicked(x, y) → {Branch}⚓
Determines if this branch has been clicked.
Parameters:
Name | Type |
---|---|
x |
number |
y |
number |
Returns:
- Type
- Branch
drawLabel()⚓
setNodeDimensions(centerX, centerY, radius)⚓
Sets the minimum and maximum coordinates of the branch.
Parameters:
Name | Type |
---|---|
centerX |
number |
centerY |
number |
radius |
number |
drawCollapsed(centerX, centerY)⚓
Draws the "collapsed tip".
Parameters:
Name | Type |
---|---|
centerX |
number |
centerY |
number |
drawLabelConnector()⚓
For aligned labels.
drawLeaf()⚓
drawHighlight(centerX, centerY)⚓
Parameters:
Name | Type |
---|---|
centerX |
number |
centerY |
number |
drawBranchLabels()⚓
drawNode()⚓
Draws the line of the branch.
getChildProperties(property) → {Array.<string>}⚓
Get property values of leaves under this branch.
Parameters:
Name | Type | Description |
---|---|---|
property |
string | property name |
Returns:
- Type
- Array.<string>
getChildCount() → {number}⚓
Returns:
- Type
- number
getChildYTotal() → {number}⚓
Returns:
- Type
- number
cascadeFlag(property, value, predicateopt)⚓
Set a boolean property of this branch and its descendants.
Parameters:
Name | Type | Attributes |
---|---|---|
property |
string | |
value |
boolean | |
predicate |
function |
<optional> |
reset()⚓
Resets the coordinates and angle of this branch and its descendants.
redrawTreeFromBranch()⚓
Set this branch to be the root.
extractChildren()⚓
Store this branch's children.
hasCollapsedAncestor() → {boolean}⚓
Walks up the tree looking for a collapsed branch.
Returns:
- Type
- boolean
collapse()⚓
expand()⚓
toggleCollapsed()⚓
setTotalLength()⚓
Sums the length of all branches from this one back to the root.
addChild(node)⚓
Add a child branch to this branch.
Parameters:
Name | Type | Description |
---|---|---|
node |
Branch | the node to add as a child |
getChildColours() → {Array.<string>}⚓
Return the node colour of all the nodes that are children of this one.
Returns:
- Type
- Array.<string>
getColour() → {string}⚓
Get the colour(s) of the branch itself.
Returns:
- Type
- string
getNwk() → {string}⚓
Create a newick representation of this branch.
Returns:
- Type
- string
getTextColour() → {string}⚓
Returns:
- Type
- string
getLabel() → {string}⚓
Ensures the return value is always a string.
Returns:
- Type
- string
getTextSize() → {number}⚓
Returns:
- Type
- number
getFontString() → {string}⚓
Returns:
- Type
- string
getLabelSize() → {number}⚓
Returns:
length of label in pixels
- Type
- number
getRadius() → {number}⚓
Returns:
- Type
- number
getDiameter() → {number}⚓
Returns:
- Type
- number
hasLabelConnector() → {boolean}⚓
Returns:
- Type
- boolean
getLabelStartX() → {number}⚓
Calculates label start position
offset + aesthetic padding
Returns:
x coordinate
- Type
- number
getHighlightLineWidth() → {number}⚓
Returns:
- Type
- number
getHighlightRadius() → {number}⚓
Returns:
- Type
- number
getHighlightSize() → {number}⚓
Combination of radius and line width
Returns:
- Type
- number
rotate()⚓
Reverses the order of the children. Runs the prerenderer again.
getChildNo() → {number}⚓
Returns:
index of this branch in its parent's array.
- Type
- number
setDisplay(options)⚓
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
getTotalLength() → {number}⚓
Returns:
the node radius plus label length if labels are shown
- Type
- number
getBounds() → {Object}⚓
Returns:
bounds
- Type
- Object
Properties:
Name | Type |
---|---|
minx |
number |
miny |
number |
maxx |
number |
maxy |
number |
getLeafStyle() → {Object}⚓
Merges global and local styles together.
Returns:
- Type
- Object
- Source:
- See: