Graph.Plot.js

Defines an abstract class for performing Graph rendering and animation.

Summary
Graph.Plot.jsDefines an abstract class for performing Graph rendering and animation.
Graph.PlotGeneric Graph rendering and animation methods.
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels (by hiding the label container).
clearLabelsClears the label container.
disposeLabelRemoves a label.
hideLabelHides the corresponding Graph.Node label.
sequenceIteratively performs an action while refreshing the state of the visualization.
animateAnimates a Graph by interpolating some Graph.Nodes properties.
plotPlots a Graph.
plotLabelPlots a label for a given node.
plotNodePlots a Graph.Node.
plotLinePlots a line.
fitsInCanvasReturns true or false if the label for the node is contained in the canvas dom element or not.

Graph.Plot

Generic Graph rendering and animation methods.

Description

An abstract class for plotting a generic graph structure.

Implemented by

Hypertree.Plot, RGraph.Plot, ST.Plot.

Access

The subclasses for this abstract class can be accessed by using the fx property of the Hypertree, RGraph, or ST instances created.

See also

Hypertree.Plot, RGraph.Plot, ST.Plot, Hypertree, RGraph, ST, Graph.

Summary
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels (by hiding the label container).
clearLabelsClears the label container.
disposeLabelRemoves a label.
hideLabelHides the corresponding Graph.Node label.
sequenceIteratively performs an action while refreshing the state of the visualization.
animateAnimates a Graph by interpolating some Graph.Nodes properties.
plotPlots a Graph.
plotLabelPlots a label for a given node.
plotNodePlots a Graph.Node.
plotLinePlots a line.
fitsInCanvasReturns true or false if the label for the node is contained in the canvas dom element or not.

Functions

getLabelContainer

getLabelContainer: function()

Lazy fetcher for the label container.

Returns

The label container DOM element.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
var labelContainer = rg.fx.getLabelContainer();
alert(labelContainer.innerHTML);

getLabel

getLabel: function(id)

Lazy fetcher for the label DOM element.

Parameters

idThe label id (which is also a Graph.Node id).

Returns

The label DOM element.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
var label = rg.fx.getLabel('someid');
alert(label.innerHTML);

hideLabels

hideLabels: function (hide)

Hides all labels (by hiding the label container).

Parameters

hideA boolean value indicating if the label container must be hidden or not.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.hideLabels(true);

clearLabels

clearLabels: function(force)

Clears the label container.

Useful when using a new visualization with the same canvas element/widget.

Parameters

forceForces deletion of all labels.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.clearLabels();

disposeLabel

disposeLabel: function(id)

Removes a label.

Parameters

idA label id (which generally is also a Graph.Node id).

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.disposeLabel('labelid');

hideLabel

hideLabel: function(node,
flag)

Hides the corresponding Graph.Node label.

Parameters

nodeA Graph.Node.  Can also be an array of Graph.Nodes.
flagIf true, nodes will be shown.  Otherwise nodes will be hidden.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.hideLabel(rg.graph.getNode('someid'), false);

sequence

sequence: function(options)

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

Parameters

optionsSome sequence options like
  • condition A function returning a boolean instance in order to stop iterations.
  • step A function to execute on each step of the iteration.
  • onComplete A function to execute when the sequence finishes.
  • duration Duration (in milliseconds) of each step.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
var i = 0;
rg.fx.sequence({
  condition: function() {
   return i == 10;
  },
  step: function() {
    alert(i++);
  },
  onComplete: function() {
   alert('done!');
  }
});

animate

animate: function(opt,
versor)

Animates a Graph by interpolating some Graph.Nodes properties.

Parameters

optAnimation options.  This object contains as properties
  • modes (required) An Array of animation types.  Possible values are “linear”, “polar”, “moebius”, “fade:nodes” and “fade:vertex”.

”linear”, “polar” and “moebius” animation options will interpolate Graph.Nodes “startPos” and “endPos” properties, storing the result in “pos”.

”fade:nodes” and “fade:vertex” animation options will interpolate Graph.Nodes and/or Graph.Adjacence “startAlpha” and “endAlpha” properties, storing the result in “alpha”.

  • duration Duration (in milliseconds) of the Animation.
  • fps Frames per second.
  • hideLabels hide labels or not during the animation.

...and other Hypertree, RGraph or ST controller methods.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.animate({
  modes: ['linear'],
  hideLabels: false
});

plot

plot: function(opt,
animating)

Plots a Graph.

Parameters

optoptional Plotting options.

Example

var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.plot();

plotLabel

plotLabel: function(canvas,
node,
controller)

Plots a label for a given node.

Parameters

canvasA Canvas instance.
nodeA Graph.Node.
controllerA configuration object.  See also Hypertree, RGraph, ST.

plotNode

plotNode: function(node,
canvas,
animating)

Plots a Graph.Node.

Parameters

nodeA Graph.Node.
canvasA Canvas element.

plotLine

plotLine: function(adj,
canvas,
animating)

Plots a line.

Parameters

adjA Graph.Adjacence.
canvasA Canvas instance.

fitsInCanvas

fitsInCanvas: function(pos,
canvas)

Returns true or false if the label for the node is contained in the canvas dom element or not.

Parameters

posA Complex instance (I’m doing duck typing here so any object with x and y parameters will do).
canvasA Canvas instance.

Returns

A boolean value specifying if the label is contained in the Canvas DOM element or not.

A generic Graph class.
getLabelContainer: function()
Lazy fetcher for the label container.
getLabel: function(id)
Lazy fetcher for the label DOM element.
hideLabels: function (hide)
Hides all labels (by hiding the label container).
clearLabels: function(force)
Clears the label container.
disposeLabel: function(id)
Removes a label.
hideLabel: function(node,
flag)
Hides the corresponding Graph.Node label.
A Graph node.
sequence: function(options)
Iteratively performs an action while refreshing the state of the visualization.
animate: function(opt,
versor)
Animates a Graph by interpolating some Graph.Nodes properties.
plot: function(opt,
animating)
Plots a Graph.
plotLabel: function(canvas,
node,
controller)
Plots a label for a given node.
plotNode: function(node,
canvas,
animating)
Plots a Graph.Node.
plotLine: function(adj,
canvas,
animating)
Plots a line.
fitsInCanvas: function(pos,
canvas)
Returns true or false if the label for the node is contained in the canvas dom element or not.
Performs plotting operations.
Performs plotting operations.
Performs plotting operations.
The main Hypertree class
The main RGraph class
The main ST class
A Graph adjacence (or edge).
A multi-purpose Canvas Class.
A multi-purpose Complex Class with common methods.
Close