Hypertree.js

Author: Nicolas Garcia Belmonte

Homepage: http://thejit.org

Version: 1.0.8a

Copyright: Copyright 2008-2009 by Nicolas Garcia Belmonte.

License: BSD License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Nicolas Garcia Belmonte ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Nicolas Garcia Belmonte BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Summary
Hypertree.jsAuthor: Nicolas Garcia Belmonte
ComplexA multi-purpose Complex Class with common methods.
Functions
ComplexComplex constructor.
cloneReturns a copy of the current object.
toPolarTransforms cartesian to polar coordinates.
normCalculates the complex norm.
squaredNormCalculates the complex squared norm.
addReturns the result of adding two complex numbers.
prodReturns the result of multiplying two complex numbers.
conjugateReturns the conjugate por this complex.
scaleReturns the result of scaling a Complex instance.
equalsComparison method.
$addReturns the result of adding two complex numbers.
$prodReturns the result of multiplying two complex numbers.
$conjugateReturns the conjugate for this complex.
$scaleReturns the result of scaling a Complex instance.
$divReturns the division of two complex numbers.
moebiusTransformationCalculates a moebius transformation for this point / complex.
PolarA multi purpose polar representation.
Functions
PolarPolar constructor.
toComplexTranslates from polar to cartesian coordinates and returns a new Complex instance.
addAdds two Polar instances.
scaleScales a polar norm.
equalsComparison method.
interpolateCalculates a polar interpolation between two points at a given delta moment.
Config<HT> global configuration object.
Properties
labelContainerid for label container
drawMainCircleshow/hide main circle
allowVariableNodeDiametersSet this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).
transformNodesApply the moebius transformation to the nodes.
nodeDiametersDiameters range.
nodeRangeValuesThe interval of the values of the first object of your dataSet array.
fpsanimation frames per second
animationTimeTime of the animation
nodeRadiusThe radius of the nodes displayed
GraphUtilA multi purpose object to do graph traversal and processing.
Functions
filterFor internal use only.
cleanCleans flags from nodes (by setting the flag property to false).
eachNodeIterates over graph nodes performing an action.
eachAdjacencyIterates over a node adjacencies applying the action function.
computeLevelsPerforms a BFS traversal setting correct level for nodes.
getNodeReturns a graph node with a specified id.
eachBFSPerforms a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnodeAfter a BFS traversal the depth property of each node has been modified.
getParentsReturns all nodes having a depth that is less than the node’s depth property.
getSubnodesCollects all subnodes for a specified node.
getClosestNodeToOriginReturns the closest node to the center of canvas.
moebiusTransformationCalculates a moebius transformation for the hyperbolic tree.
GraphOpAn object holding unary and binary graph operations such as removingNodes, removingEdges, adding two graphs and morphing.
Functions
removeNodeRemoves one or more nodes from the visualization.
removeEdgeRemoves one or more edges from the visualization.
sumAdds a new graph to the visualization.
morphThis method will morph the current visualized graph into the new json representation passed in the method.
GraphPlotAn object that performs specific radial layouts for a generic graph structure.
Properties
labelsHiddenA flag value indicating if node labels are being displayed or not.
labelContainerLabel DOM element
labelsLabel DOM elements hash.
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels.
clearLabelsClears the label container.
disposeLabelRemoves a label.
sequenceIteratively performs an action while refreshing the state of the visualization.
animateAnimates the graph by performing a moebius transformation from the current state to the given position.
plotPlots a Graph.
plotNodePlots a graph node.
plotLinePlots a hyperline between two nodes.
computeArcThroughTwoPointsCalculates the arc parameters through two points.
plotLabelPlots a label for a given node.
hideLabelHides a label having node.id as id.
senseFor private use only: sets angle direction to clockwise (true) or counterclockwise (false).
HypertreeAn animated Graph with radial layout.
Functions
HypertreeCreates a new Hypertree instance.
loadTreeLoads a Graph from a json tree object http://blog.thejit.org
loadGraphLoads a Graph from a json graph object http://blog.thejit.org
flagRootFlags a node specified by id as root.
unflagRootUnflags all nodes.
getRootReturns the node flagged as root.
loadTreeFromJSONLoads a Hypertree from a json object http://blog.thejit.org/?p=7
loadGraphFromJSONLoads a Hypertree from a json object http://blog.thejit.org
refreshComputes positions and then plots.
repositionComputes new positions and repositions the tree where it was before.
plotPlots the Hypertree
computeComputes the graph nodes positions and stores this positions on property.
computePositionsPerforms the main algorithm for computing node positions.
setAngularWidthForNodesSets nodes angular widths.
setSubtreesAngularWidthsSets subtrees angular widths.
setSubtreeAngularWidthSets the angular width for a subtree.
computeAngularWidthsComputes nodes and subtrees angular widths.
onClickPerforms all calculations and animation when clicking on a label specified by id.
GraphA generic Graph class.
Functions and Properties
GraphCreates a new Graph instance.
nodesgraph nodes
getNodeReturns a Graph.Node from a specified id.
getAdjacenceReturns an array of Graph.Adjacence that connects nodes with id id and id2.
addNodeAdds a node.
addAdjacenceConnects nodes specified by obj and obj2.
removeNodeRemoves a Graph.Node from Graph that matches the specified id.
removeAdjacenceRemoves a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNodeReturns a Boolean instance indicating if node belongs to graph or not.
Graph.NodeBehaviour of the Graph node.
Functions
Graph.NodeNode constructor.
Properties
idA node’s id
nameA node’s name
dataThe dataSet object http://blog.thejit.org/?p=7
drawnNode flag
angle spanallowed angle span for adjacencies placement
posnode position
startPosnode from position
endPosnode to position
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
adjacenciesnode adjacencies
Functions
adjacentToIndicates if the node is adjacent to the node indicated by the specified id
getAdjacencyReturns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacencyConnects the node to the specified by id.
removeAdjacencyDeletes the Graph.Adjacence by id.
Graph.AdjacenceCreates a new Graph adjacence.
Properties
nodeFromOne of the two Graph.Nodes connected by this edge.
nodeToOne of the two Graph.Nodes connected by this edge.
dataA dataset object
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
TransAn object containing multiple type of transformations.
AnimationAn object that performs animations.

Complex

A multi-purpose Complex Class with common methods.

Summary
Functions
ComplexComplex constructor.
cloneReturns a copy of the current object.
toPolarTransforms cartesian to polar coordinates.
normCalculates the complex norm.
squaredNormCalculates the complex squared norm.
addReturns the result of adding two complex numbers.
prodReturns the result of multiplying two complex numbers.
conjugateReturns the conjugate por this complex.
scaleReturns the result of scaling a Complex instance.
equalsComparison method.
$addReturns the result of adding two complex numbers.
$prodReturns the result of multiplying two complex numbers.
$conjugateReturns the conjugate for this complex.
$scaleReturns the result of scaling a Complex instance.
$divReturns the division of two complex numbers.
moebiusTransformationCalculates a moebius transformation for this point / complex.

Functions

Complex

var Complex= function()

Complex constructor.

Parameters

reA real number.
imAn real number representing the imaginary part.

Returns

A new Complex instance.

clone

clone: function()

Returns a copy of the current object.

Returns

A copy of the real object.

toPolar

toPolar: function()

Transforms cartesian to polar coordinates.

Returns

A new Polar instance.

norm

norm: function ()

Calculates the complex norm.

Returns

A real number representing the complex norm.

squaredNorm

squaredNorm: function ()

Calculates the complex squared norm.

Returns

A real number representing the complex squared norm.

add

add: function(pos)

Returns the result of adding two complex numbers.  Does not alter the original object.

Parameters

posA Complex initialized instance.

Returns

The result of adding two complex numbers.

prod

prod: function(pos)

Returns the result of multiplying two complex numbers.  Does not alter the original object.

Parameters

posA Complex initialized instance.

Returns

The result of multiplying two complex numbers.

conjugate

conjugate: function()

Returns the conjugate por this complex.

Returns

The conjugate por this complex.

scale

scale: function(factor)

Returns the result of scaling a Complex instance.  Does not alter the original object.

Parameters

factorA scale factor.

Returns

The result of scaling this complex to a factor.

equals

equals: function(c)

Comparison method.

$add

$add: function(pos)

Returns the result of adding two complex numbers.  Alters the original object.

Parameters

posA Complex initialized instance.

Returns

The result of adding two complex numbers.

$prod

$prod:function(pos)

Returns the result of multiplying two complex numbers.  Alters the original object.

Parameters

posA Complex initialized instance.

Returns

The result of multiplying two complex numbers.

$conjugate

$conjugate: function()

Returns the conjugate for this complex.  Alters the original object.

Returns

The conjugate for this complex.

$scale

$scale: function(factor)

Returns the result of scaling a Complex instance.  Alters the original object.

Parameters

factorA scale factor.

Returns

The result of scaling this complex to a factor.

$div

$div: function(pos)

Returns the division of two complex numbers.  Alters the original object.

Parameters

posA Complex number.

Returns

The result of scaling this complex to a factor.

moebiusTransformation

moebiusTransformation: function(c)

Calculates a moebius transformation for this point / complex.  For more information go to: http://en.wikipedia.org/wiki/Moebius_transformation.

Parameters

cAn initialized Complex instance representing a translation Vector.

Polar

A multi purpose polar representation.

Summary
Functions
PolarPolar constructor.
toComplexTranslates from polar to cartesian coordinates and returns a new Complex instance.
addAdds two Polar instances.
scaleScales a polar norm.
equalsComparison method.
interpolateCalculates a polar interpolation between two points at a given delta moment.

Functions

Polar

var Polar = function(theta,
rho)

Polar constructor.

Parameters

thetaAn angle.
rhoThe norm.

Returns

A new Polar instance.

toComplex

toComplex: function()

Translates from polar to cartesian coordinates and returns a new Complex instance.

Returns

A new Complex instance.

add

add: function(polar)

Adds two Polar instances.

Returns

A new Polar instance.

scale

scale: function(number)

Scales a polar norm.

Returns

A new Polar instance.

equals

equals: function(c)

Comparison method.

interpolate

interpolate: function(elem,
delta)

Calculates a polar interpolation between two points at a given delta moment.

Returns

A new Polar instance representing an interpolation between this and elem

Config

<HT> global configuration object.  Contains important properties to enable customization and proper behavior for the <HT>.

Summary
Properties
labelContainerid for label container
drawMainCircleshow/hide main circle
allowVariableNodeDiametersSet this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).
transformNodesApply the moebius transformation to the nodes.
nodeDiametersDiameters range.
nodeRangeValuesThe interval of the values of the first object of your dataSet array.
fpsanimation frames per second
animationTimeTime of the animation
nodeRadiusThe radius of the nodes displayed

Properties

labelContainer

id for label container

drawMainCircle

show/hide main circle

allowVariableNodeDiameters

Set this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).  This will allow you to represent weighted tree/graph nodes.

transformNodes

Apply the moebius transformation to the nodes.  Applying a moebius transformation to the nodes might be annoying to the user if you are plotting a tree/graph with weighted nodes, since they will deformed by the transformation and thus not having a meaninfull comparative proportion.

nodeDiameters

Diameters range.

nodeRangeValues

The interval of the values of the first object of your dataSet array.  A superset of the values can also be specified.

fps

animation frames per second

animationTime

Time of the animation

nodeRadius

The radius of the nodes displayed

GraphUtil

A multi purpose object to do graph traversal and processing.

Summary
Functions
filterFor internal use only.
cleanCleans flags from nodes (by setting the flag property to false).
eachNodeIterates over graph nodes performing an action.
eachAdjacencyIterates over a node adjacencies applying the action function.
computeLevelsPerforms a BFS traversal setting correct level for nodes.
getNodeReturns a graph node with a specified id.
eachBFSPerforms a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnodeAfter a BFS traversal the depth property of each node has been modified.
getParentsReturns all nodes having a depth that is less than the node’s depth property.
getSubnodesCollects all subnodes for a specified node.
getClosestNodeToOriginReturns the closest node to the center of canvas.
moebiusTransformationCalculates a moebius transformation for the hyperbolic tree.

Functions

filter

filter: function(param)

For internal use only.  Provides a filtering function based on flags.

clean

clean: function(graph)

Cleans flags from nodes (by setting the flag property to false).

eachNode

eachNode: function(graph,
action,
flags)

Iterates over graph nodes performing an action.

eachAdjacency

eachAdjacency: function(node,
action,
flags)

Iterates over a node adjacencies applying the action function.

computeLevels

computeLevels: function(graph,
id,
flags)

Performs a BFS traversal setting correct level for nodes.

getNode

getNode: function(graph,
id)

Returns a graph node with a specified id.

eachBFS

eachBFS: function(graph,
id,
action,
flags)

Performs a BFS traversal of a graph beginning by the node of id id and performing action on each node.  This traversal ignores nodes or edges having the property ignore setted to true.

eachSubnode

eachSubnode: function(graph,
node,
action,
flags)

After a BFS traversal the depth property of each node has been modified.  Now the graph can be traversed as a tree.  This method iterates for each subnode that has depth larger than the specified node.

getParents

getParents: function(graph,
node)

Returns all nodes having a depth that is less than the node’s depth property.

getSubnodes

getSubnodes: function(graph,
id,
level,
flags)

Collects all subnodes for a specified node.  The level parameter filters nodes having relative depth of level from the root node.

getClosestNodeToOrigin

getClosestNodeToOrigin: function(graph,
prop,
flags)

Returns the closest node to the center of canvas.

moebiusTransformation

moebiusTransformation: function(graph,
pos,
prop,
startPos,
flags)

Calculates a moebius transformation for the hyperbolic tree.  For more information go to: http://en.wikipedia.org/wiki/Moebius_transformation

Parameters

thetaRotation angle.
cTranslation Complex.

GraphOp

An object holding unary and binary graph operations such as removingNodes, removingEdges, adding two graphs and morphing.

Summary
Functions
removeNodeRemoves one or more nodes from the visualization.
removeEdgeRemoves one or more edges from the visualization.
sumAdds a new graph to the visualization.
morphThis method will morph the current visualized graph into the new json representation passed in the method.

Functions

removeNode

removeNode: function(viz,
node,
opt)

Removes one or more nodes from the visualization.  It can also perform several animations like fading sequentially, fading concurrently, iterating or replotting.

Parameters

vizThe visualization object (an RGraph instance in this case).
nodeThe node’s id.  Can also be an array having many ids.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, fade:con or iter.  The other property is the duration in milliseconds.

removeEdge

removeEdge: function(viz,
vertex,
opt)

Removes one or more edges from the visualization.  It can also perform several animations like fading sequentially, fading concurrently, iterating or replotting.

Parameters

vizThe visualization object (an RGraph instance in this case).
vertexAn array having two strings which are the ids of the nodes connected by this edge: [‘id1’, ‘id2’].  Can also be a two dimensional array holding many edges: [[‘id1’, ‘id2’], [‘id3’, ‘id4’], ...].
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, fade:con or iter.  The other property is the duration in milliseconds.

sum

sum: function(viz,
json,
opt)

Adds a new graph to the visualization.  The json graph (or tree) must at least have a common node with the current graph plotted by the visualization.  The resulting graph can be defined as follows: http://mathworld.wolfram.com/GraphSum.html

Parameters

vizThe visualization object (an RGraph instance in this case).
jsonA json tree http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/, a json graph http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/ or an extended json graph http://blog.thejit.org/2008/08/05/weighted-nodes-weighted-edges/.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, or fade:con.  The other property is the duration in milliseconds.

morph

morph: function(viz,
json,
opt)

This method will morph the current visualized graph into the new json representation passed in the method.  Can also perform multiple animations.  The json object must at least have the root node in common with the current visualized graph.

Parameters

vizThe visualization object (an RGraph instance in this case).
jsonA json tree http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/, a json graph http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/ or an extended json graph http://blog.thejit.org/2008/08/05/weighted-nodes-weighted-edges/.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, or fade.  The other property is the duration in milliseconds.

GraphPlot

An object that performs specific radial layouts for a generic graph structure.

Summary
Properties
labelsHiddenA flag value indicating if node labels are being displayed or not.
labelContainerLabel DOM element
labelsLabel DOM elements hash.
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels.
clearLabelsClears the label container.
disposeLabelRemoves a label.
sequenceIteratively performs an action while refreshing the state of the visualization.
animateAnimates the graph by performing a moebius transformation from the current state to the given position.
plotPlots a Graph.
plotNodePlots a graph node.
plotLinePlots a hyperline between two nodes.
computeArcThroughTwoPointsCalculates the arc parameters through two points.
plotLabelPlots a label for a given node.
hideLabelHides a label having node.id as id.
senseFor private use only: sets angle direction to clockwise (true) or counterclockwise (false).

Properties

labelsHidden

A flag value indicating if node labels are being displayed or not.

labelContainer

Label DOM element

labels

Label DOM elements hash.

Functions

getLabelContainer

getLabelContainer: function()

Lazy fetcher for the label container.

getLabel

getLabel: function(id)

Lazy fetcher for the label DOM element.

hideLabels

hideLabels: function (hide)

Hides all labels.

clearLabels

clearLabels: function(viz)

Clears the label container.

disposeLabel

disposeLabel: function(id)

Removes a label.

sequence

sequence: function(viz,
options)

Iteratively performs an action while refreshing the state of the visualization.

animate

animate: function(viz,
opt,
versor)

Animates the graph by performing a moebius transformation from the current state to the given position.

plot

plot: function(viz,
opt)

Plots a Graph.

plotNode

plotNode: function(node,
canvas)

Plots a graph node.

plotLine

plotLine: function(adj,
canvas)

Plots a hyperline between two nodes.  A hyperline is an arc of a circle which is orthogonal to the main circle.

computeArcThroughTwoPoints

computeArcThroughTwoPoints: function(p1,
p2)

Calculates the arc parameters through two points.  More information in http://en.wikipedia.org/wiki/Poincar%C3%A9_disc_model#Analytic_geometry_constructions_in_the_hyperbolic_plane

plotLabel

plotLabel: function(canvas,
node,
controller)

Plots a label for a given node.

hideLabel

hideLabel: function(node)

Hides a label having node.id as id.

sense

sense: function(angleBegin,
angleEnd)

For private use only: sets angle direction to clockwise (true) or counterclockwise (false).

Parameters

angleBeginStarting angle for drawing the arc.
angleEndThe HyperLine will be drawn from angleBegin to angleEnd.

Returns

A Boolean instance describing the sense for drawing the HyperLine.

Hypertree

An animated Graph with radial layout.

Go to http://blog.thejit.org/?p=7 to know what kind of JSON structure feeds this object.

Go to http://blog.thejit.org/?p=8 to know what kind of controller this class accepts.

Refer to the Config object to know what properties can be modified in order to customize this object.

The simplest way to create and layout a Hypertree is

var canvas= new Canvas('infovis', {});
var ht= new Hypertree(canvas);
ht.loadTreeFromJSON(json);
ht.compute();
ht.plot();
ht.prepareCanvasEvents();

A user should only interact with the Canvas, Hypertree and Config objects/classes.  By implementing Hypertree controllers you can also customize the Hypertree behavior.

Summary
Functions
HypertreeCreates a new Hypertree instance.
loadTreeLoads a Graph from a json tree object http://blog.thejit.org
loadGraphLoads a Graph from a json graph object http://blog.thejit.org
flagRootFlags a node specified by id as root.
unflagRootUnflags all nodes.
getRootReturns the node flagged as root.
loadTreeFromJSONLoads a Hypertree from a json object http://blog.thejit.org/?p=7
loadGraphFromJSONLoads a Hypertree from a json object http://blog.thejit.org
refreshComputes positions and then plots.
repositionComputes new positions and repositions the tree where it was before.
plotPlots the Hypertree
computeComputes the graph nodes positions and stores this positions on property.
computePositionsPerforms the main algorithm for computing node positions.
setAngularWidthForNodesSets nodes angular widths.
setSubtreesAngularWidthsSets subtrees angular widths.
setSubtreeAngularWidthSets the angular width for a subtree.
computeAngularWidthsComputes nodes and subtrees angular widths.
onClickPerforms all calculations and animation when clicking on a label specified by id.

Functions

Hypertree

var Hypertree = function(canvas,
controller)

Creates a new Hypertree instance.

Parameters

canvasA Canvas instance.
controlleroptional a Hypertree controller http://blog.thejit.org/?p=8

loadTree

loadTree: function(json)

Loads a Graph from a json tree object http://blog.thejit.org

loadGraph

loadGraph: function(json)

Loads a Graph from a json graph object http://blog.thejit.org

flagRoot

flagRoot: function(id)

Flags a node specified by id as root.

unflagRoot

unflagRoot: function()

Unflags all nodes.

getRoot

getRoot: function()

Returns the node flagged as root.

loadTreeFromJSON

loadTreeFromJSON: function(json)

Loads a Hypertree from a json object http://blog.thejit.org/?p=7

loadGraphFromJSON

loadGraphFromJSON: function(json,
i)

Loads a Hypertree from a json object http://blog.thejit.org

refresh

refresh: function(reposition)

Computes positions and then plots.

reposition

reposition: function()

Computes new positions and repositions the tree where it was before.  (For calculating new positions the root must be on its origin, and that may lead to an undesired repositioning of the graph, this method attempts to solve this problem.

plot

plot: function()

Plots the Hypertree

compute

compute: function(property)

Computes the graph nodes positions and stores this positions on property.

computePositions

computePositions: function(property)

Performs the main algorithm for computing node positions.

setAngularWidthForNodes

setAngularWidthForNodes: function()

Sets nodes angular widths.

setSubtreesAngularWidths

Sets subtrees angular widths.

setSubtreeAngularWidth

setSubtreeAngularWidth: function(elem)

Sets the angular width for a subtree.

computeAngularWidths

computeAngularWidths: function ()

Computes nodes and subtrees angular widths.

onClick

onClick: function(id)

Performs all calculations and animation when clicking on a label specified by id.  The label id is the same id as its homologue node.

Graph

A generic Graph class.

Summary
Functions and Properties
GraphCreates a new Graph instance.
nodesgraph nodes
getNodeReturns a Graph.Node from a specified id.
getAdjacenceReturns an array of Graph.Adjacence that connects nodes with id id and id2.
addNodeAdds a node.
addAdjacenceConnects nodes specified by obj and obj2.
removeNodeRemoves a Graph.Node from Graph that matches the specified id.
removeAdjacenceRemoves a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNodeReturns a Boolean instance indicating if node belongs to graph or not.

Functions and Properties

Graph

var Graph= function()

Creates a new Graph instance.

nodes

graph nodes

getNode

getNode: function(id)

Returns a Graph.Node from a specified id.

getAdjacence

getAdjacence: function (id,
id2)

Returns an array of Graph.Adjacence that connects nodes with id id and id2.

addNode

addNode: function(obj)

Adds a node.

Parameters

objA Graph.Node object.

addAdjacence

addAdjacence: function (obj,
obj2,
weight)

Connects nodes specified by obj and obj2.  If not found, nodes are created.

Parameters

obja Graph.Node object.
obj2Another Graph.Node object.
dataA DataSet object.

removeNode

removeNode: function(id)

Removes a Graph.Node from Graph that matches the specified id.

removeAdjacence

removeAdjacence: function(id1,
id2)

Removes a Graph.Adjacence from Graph that matches the specified id1 and id2.

hasNode

hasNode: function(id)

Returns a Boolean instance indicating if node belongs to graph or not.

Parameters

idNode id.

Returns

A Boolean instance indicating if node belongs to graph or not.

Graph.Node

Behaviour of the Graph node.

Summary
Functions
Graph.NodeNode constructor.
Properties
idA node’s id
nameA node’s name
dataThe dataSet object http://blog.thejit.org/?p=7
drawnNode flag
angle spanallowed angle span for adjacencies placement
posnode position
startPosnode from position
endPosnode to position
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
adjacenciesnode adjacencies
Functions
adjacentToIndicates if the node is adjacent to the node indicated by the specified id
getAdjacencyReturns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacencyConnects the node to the specified by id.
removeAdjacencyDeletes the Graph.Adjacence by id.

Functions

Graph.Node

Graph.Node = function(id,
name,
data)

Node constructor.

Parameters

idThe node unique identifier id.
nameA node’s name.
dataPlace to store some extra information (can be left to null).

Returns

A new Graph.Node instance.

Properties

id

A node’s id

name

A node’s name

data

The dataSet object http://blog.thejit.org/?p=7

drawn

Node flag

angle span

allowed angle span for adjacencies placement

pos

node position

startPos

node from position

endPos

node to position

alpha

node alpha

startAlpha

node start alpha

endAlpha

node end alpha

adjacencies

node adjacencies

Functions

adjacentTo

adjacentTo: function(node)

Indicates if the node is adjacent to the node indicated by the specified id

Parameters

idA node id.

Returns

A Boolean instance indicating whether this node is adjacent to the specified by id or not.

getAdjacency

getAdjacency: function(id)

Returns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.

Parameters

idA node id.

addAdjacency

addAdjacency: function(node,
data)

Connects the node to the specified by id.

Parameters

idA node id.

removeAdjacency

removeAdjacency: function(id)

Deletes the Graph.Adjacence by id.

Parameters

idA node id.

Graph.Adjacence

Creates a new Graph adjacence.

Summary
Properties
nodeFromOne of the two Graph.Nodes connected by this edge.
nodeToOne of the two Graph.Nodes connected by this edge.
dataA dataset object
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha

Properties

nodeFrom

One of the two Graph.Nodes connected by this edge.

nodeTo

One of the two Graph.Nodes connected by this edge.

data

A dataset object

alpha

node alpha

startAlpha

node start alpha

endAlpha

node end alpha

Trans

An object containing multiple type of transformations.  Based on the mootools library http://mootools.net.

Animation

An object that performs animations.  Based on Fx.Base from Mootools.

var Complex= function()
Complex constructor.
clone: function()
Returns a copy of the current object.
toPolar: function()
Transforms cartesian to polar coordinates.
norm: function ()
Calculates the complex norm.
squaredNorm: function ()
Calculates the complex squared norm.
add: function(pos)
Returns the result of adding two complex numbers.
prod: function(pos)
Returns the result of multiplying two complex numbers.
conjugate: function()
Returns the conjugate por this complex.
scale: function(factor)
Returns the result of scaling a Complex instance.
equals: function(c)
Comparison method.
$add: function(pos)
Returns the result of adding two complex numbers.
$prod:function(pos)
Returns the result of multiplying two complex numbers.
$conjugate: function()
Returns the conjugate for this complex.
$scale: function(factor)
Returns the result of scaling a Complex instance.
$div: function(pos)
Returns the division of two complex numbers.
moebiusTransformation: function(c)
Calculates a moebius transformation for this point / complex.
var Polar = function(theta,
rho)
Polar constructor.
toComplex: function()
Translates from polar to cartesian coordinates and returns a new Complex instance.
A multi-purpose Complex Class with common methods.
add: function(polar)
Adds two Polar instances.
scale: function(number)
Scales a polar norm.
equals: function(c)
Comparison method.
interpolate: function(elem,
delta)
Calculates a polar interpolation between two points at a given delta moment.
filter: function(param)
For internal use only.
clean: function(graph)
Cleans flags from nodes (by setting the flag property to false).
eachNode: function(graph,
action,
flags)
Iterates over graph nodes performing an action.
eachAdjacency: function(node,
action,
flags)
Iterates over a node adjacencies applying the action function.
computeLevels: function(graph,
id,
flags)
Performs a BFS traversal setting correct level for nodes.
getNode: function(graph,
id)
Returns a graph node with a specified id.
eachBFS: function(graph,
id,
action,
flags)
Performs a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnode: function(graph,
node,
action,
flags)
After a BFS traversal the depth property of each node has been modified.
getParents: function(graph,
node)
Returns all nodes having a depth that is less than the node’s depth property.
getSubnodes: function(graph,
id,
level,
flags)
Collects all subnodes for a specified node.
getClosestNodeToOrigin: function(graph,
prop,
flags)
Returns the closest node to the center of canvas.
moebiusTransformation: function(graph,
pos,
prop,
startPos,
flags)
Calculates a moebius transformation for the hyperbolic tree.
removeNode: function(viz,
node,
opt)
Removes one or more nodes from the visualization.
removeEdge: function(viz,
vertex,
opt)
Removes one or more edges from the visualization.
sum: function(viz,
json,
opt)
Adds a new graph to the visualization.
morph: function(viz,
json,
opt)
This method will morph the current visualized graph into the new json representation passed in the method.
getLabelContainer: function()
Lazy fetcher for the label container.
getLabel: function(id)
Lazy fetcher for the label DOM element.
hideLabels: function (hide)
Hides all labels.
clearLabels: function(viz)
Clears the label container.
disposeLabel: function(id)
Removes a label.
sequence: function(viz,
options)
Iteratively performs an action while refreshing the state of the visualization.
animate: function(viz,
opt,
versor)
Animates the graph by performing a moebius transformation from the current state to the given position.
plot: function(viz,
opt)
Plots a Graph.
plotNode: function(node,
canvas)
Plots a graph node.
plotLine: function(adj,
canvas)
Plots a hyperline between two nodes.
computeArcThroughTwoPoints: function(p1,
p2)
Calculates the arc parameters through two points.
plotLabel: function(canvas,
node,
controller)
Plots a label for a given node.
hideLabel: function(node)
Hides a label having node.id as id.
sense: function(angleBegin,
angleEnd)
For private use only: sets angle direction to clockwise (true) or counterclockwise (false).
var Hypertree = function(canvas,
controller)
Creates a new Hypertree instance.
loadTree: function(json)
Loads a Graph from a json tree object http://blog.thejit.org
loadGraph: function(json)
Loads a Graph from a json graph object http://blog.thejit.org
flagRoot: function(id)
Flags a node specified by id as root.
unflagRoot: function()
Unflags all nodes.
getRoot: function()
Returns the node flagged as root.
loadTreeFromJSON: function(json)
Loads a Hypertree from a json object http://blog.thejit.org/?p=7
loadGraphFromJSON: function(json,
i)
Loads a Hypertree from a json object http://blog.thejit.org
refresh: function(reposition)
Computes positions and then plots.
reposition: function()
Computes new positions and repositions the tree where it was before.
plot: function()
Plots the Hypertree
compute: function(property)
Computes the graph nodes positions and stores this positions on property.
computePositions: function(property)
Performs the main algorithm for computing node positions.
setAngularWidthForNodes: function()
Sets nodes angular widths.
setSubtreeAngularWidth: function(elem)
Sets the angular width for a subtree.
computeAngularWidths: function ()
Computes nodes and subtrees angular widths.
onClick: function(id)
Performs all calculations and animation when clicking on a label specified by id.
var Graph= function()
Creates a new Graph instance.
getNode: function(id)
Returns a Graph.Node from a specified id.
Behaviour of the Graph node.
getAdjacence: function (id,
id2)
Returns an array of Graph.Adjacence that connects nodes with id id and id2.
Creates a new Graph adjacence.
addNode: function(obj)
Adds a node.
addAdjacence: function (obj,
obj2,
weight)
Connects nodes specified by obj and obj2.
removeNode: function(id)
Removes a Graph.Node from Graph that matches the specified id.
removeAdjacence: function(id1,
id2)
Removes a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNode: function(id)
Returns a Boolean instance indicating if node belongs to graph or not.
A generic Graph class.
Graph.Node = function(id,
name,
data)
Node constructor.
adjacentTo: function(node)
Indicates if the node is adjacent to the node indicated by the specified id
getAdjacency: function(id)
Returns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacency: function(node,
data)
Connects the node to the specified by id.
removeAdjacency: function(id)
Deletes the Graph.Adjacence by id.
A multi purpose polar representation.
HT global configuration object.
A multi-purpose Canvas object decorator.
Close