Packageflare.vis.data
Classpublic class Data
InheritanceData Inheritance flash.events.EventDispatcher
SubclassesTree

Data structure for managing a collection of visual data objects. The Data class manages both unstructured data and data organized in a general graph (or network structure), maintaining collections of both nodes and edges. Collections of data sprites are maintained by DataList instances. The individual data lists provide methods for accessing, manipulating, sorting, and generating statistics about the visual data objects.

In addition to the required nodes and edges lists, clients can add new custom lists (for example, to manage a selected subset of the data) by using the addGroup method and then accessing the list with the group method. Individual data groups can be directly processed by many of the visualization operators in the flare.vis.operator package.

While Data objects maintain a collection of visual DataSprites, they are not themselves visual object containers. Instead a Data instance is used as input to a Visualization that is responsible for processing the DataSprite instances and adding them to the Flash display list.

The data class also manages the automatic generation of spanning trees over a graph when needed for tree-based operations (such as tree layout algorithms). This implemented by a flare.analytics.graph.SpanningTree operator which can be parameterized using the treePolicy, treeEdgeWeight, and root properties of this class. Alternatively, clients can create their own spanning trees as a Tree

See also

flare.vis.data.DataList
flare.analytics.graph.SpanningTree


Public Properties
 PropertyDefined by
  directedEdges : Boolean
The default directedness of new edges.
Data
  edges : DataList
[read-only] The collection of EdgeSprites.
Data
  length : int
[read-only] The total number of items (nodes and edges) in the data.
Data
  nodes : DataList
[read-only] The collection of NodeSprites.
Data
  root : NodeSprite
The root node of the spanning tree.
Data
  tree : Tree
A spanning tree for this graph.
Data
  treeEdgeWeight : Function
The edge weight function for computing a minimum spanning tree.
Data
  treePolicy : String
The spanning tree creation policy.
Data
Protected Properties
 PropertyDefined by
  _edges : DataList
Internal list of EdgeSprites.
Data
  _groups : Object
Internal set of data groups.
Data
  _nodes : DataList
Internal list of NodeSprites.
Data
  _root : NodeSprite = null
The root node of the spanning tree.
Data
  _span : TreeBuilder
The spanning tree constructor class.
Data
  _tree : Tree = null
The the spanning tree.
Data
Public Methods
 MethodDefined by
  
Data(directedEdges:Boolean = false)
Creates a new Data instance.
Data
  
Add an edge to this data set.
Data
  
addEdgeFor(source:NodeSprite, target:NodeSprite, directed:Object = null, data:Object = null):EdgeSprite
Creates a new edge between the given nodes and adds it to the data collection.
Data
  
addGroup(name:String, group:DataList = null):DataList
Adds a new data group.
Data
  
addNode(d:Object = null):NodeSprite
Adds a node to this data collection.
Data
  
clear():void
Clears this data set, removing all nodes and edges.
Data
  
contains(d:DataSprite):Boolean
Indicates if this Data object contains the input DataSprite.
Data
  
createEdges(sortBy:* = null, groupBy:Boolean = null, ignoreExistingEdges:* = false):void
Generates edges for this data collection that connect the nodes according to the input properties.
Data
  
fromArray(a:Array):Data
[static] Creates a new Data instance from an array of tuples.
Data
  
[static] Creates a new Data instance from a data set.
Data
  
group(name:String):DataList
Retrieves the data group with the given name.
Data
  
remove(d:DataSprite):Boolean
Removes a DataSprite (node or edge) from this data collection.
Data
  
Removes an edge from this data set.
Data
  
removeGroup(name:String):DataList
Removes a data group.
Data
  
Removes a node from this data set.
Data
  
visit(v:Function, group:String = null, filter:Boolean = null, reverse:* = false):Boolean
Visit items, invoking a function on all visited elements.
Data
Protected Methods
 MethodDefined by
  
newEdge(s:NodeSprite, t:NodeSprite, d:Boolean, data:Object):EdgeSprite
Internal function for creating a new edge.
Data
  
newNode(data:Object):NodeSprite
Internal function for creating a new node.
Data
Events
 EventSummaryDefined by
  
add
 Data
    Data
Public Constants
 ConstantDefined by
  EDGES : String = "edges"
[static] Constant indicating the edges in a Data object.
Data
  NODES : String = "nodes"
[static] Constant indicating the nodes in a Data object.
Data
Property detail
directedEdgesproperty
public var directedEdges:Boolean

The default directedness of new edges.

_edgesproperty 
protected var _edges:DataList

Internal list of EdgeSprites.

edgesproperty 
edges:DataList  [read-only]

The collection of EdgeSprites.

Implementation
    public function get edges():DataList
_groupsproperty 
protected var _groups:Object

Internal set of data groups.

lengthproperty 
length:int  [read-only]

The total number of items (nodes and edges) in the data.

Implementation
    public function get length():int
_nodesproperty 
protected var _nodes:DataList

Internal list of NodeSprites.

nodesproperty 
nodes:DataList  [read-only]

The collection of NodeSprites.

Implementation
    public function get nodes():DataList
_rootproperty 
protected var _root:NodeSprite = null

The root node of the spanning tree.

rootproperty 
root:NodeSprite  [read-write]

The root node of the spanning tree.

Implementation
    public function get root():NodeSprite
    public function set root(value:NodeSprite):void
_spanproperty 
protected var _span:TreeBuilder

The spanning tree constructor class.

_treeproperty 
protected var _tree:Tree = null

The the spanning tree.

treeproperty 
tree:Tree  [read-write]

A spanning tree for this graph. The spanning tree generated is determined by the root, treePolicy, and treeEdgeWeight properties. By default, the tree is built using a breadth-first spanning tree using the first node in the graph as the root.

Implementation
    public function get tree():Tree
    public function set tree(value:Tree):void
treeEdgeWeightproperty 
treeEdgeWeight:Function  [read-write]

The edge weight function for computing a minimum spanning tree. This function will only have an effect if the treePolicy is SpanningTree.MINIMUM_SPAN

Implementation
    public function get treeEdgeWeight():Function
    public function set treeEdgeWeight(value:Function):void
treePolicyproperty 
treePolicy:String  [read-write]

The spanning tree creation policy.

Implementation
    public function get treePolicy():String
    public function set treePolicy(value:String):void

See also

Constructor detail
Data()constructor
public function Data(directedEdges:Boolean = false)

Creates a new Data instance.

Parameters
directedEdges:Boolean (default = false) — the default directedness of new edges
Method detail
addEdge()method
public function addEdge(e:EdgeSprite):EdgeSprite

Add an edge to this data set. The input must be of type EdgeSprite, and must have both source and target nodes that are already in this data set. If any of these conditions are not met, this method will return null. Note that no exception will be thrown on failures.

Parameters
e:EdgeSprite — the EdgeSprite to add

Returns
EdgeSprite — the newly added EdgeSprite
addEdgeFor()method 
public function addEdgeFor(source:NodeSprite, target:NodeSprite, directed:Object = null, data:Object = null):EdgeSprite

Creates a new edge between the given nodes and adds it to the data collection.

Parameters
source:NodeSprite — the source node (must already be in this data set)
 
target:NodeSprite — the target node (must already be in this data set)
 
directed:Object (default = null) — indicates the directedness of the edge (null to use this Data's default, true for directed, false for undirected)
 
data:Object (default = null) — a data tuple containing data values for the edge instance. If non-null, this will become the EdgeSprite's data property.

Returns
EdgeSprite — the newly added EdgeSprite
addGroup()method 
public function addGroup(name:String, group:DataList = null):DataList

Adds a new data group. If a group of the same name already exists, it will be replaced, except for the groups "nodes" and "edges", which can not be replaced.

Parameters
name:String — the name of the group to add
 
group:DataList (default = null) — the data list to add, if null a new, empty DataList instance will be created.

Returns
DataList — the added data group
addNode()method 
public function addNode(d:Object = null):NodeSprite

Adds a node to this data collection.

Parameters
d:Object (default = null) — either a data tuple or NodeSprite object. If the input is a non-null data tuple, this will become the new node's data property. If the input is a NodeSprite, it will be directly added to the collection.

Returns
NodeSprite — the newly added NodeSprite
clear()method 
public function clear():void

Clears this data set, removing all nodes and edges.

contains()method 
public function contains(d:DataSprite):Boolean

Indicates if this Data object contains the input DataSprite.

Parameters
d:DataSprite — the DataSprite to check for containment

Returns
Boolean — true if the sprite is in this data collection, false otherwise.
createEdges()method 
public function createEdges(sortBy:* = null, groupBy:Boolean = null, ignoreExistingEdges:* = false):void

Generates edges for this data collection that connect the nodes according to the input properties. The nodes are sorted by the sort argument and grouped by the group-by argument. All nodes with the same group are sequentially connected to each other in sorted order by new edges. This method is useful for generating line charts from a plot of nodes.

If an edge already exists between nodes, by default this method will not add a new edge. Use the ignoreExistingEdges argument to change this behavior.

Parameters
sortBy:* (default = null) — the criteria for sorting the nodes, using the format of flare.util.Sort. The input can either be a string with a single property name, or an array of property names. Items are sorted in ascending order by default, prefix a property name with a "-" (minus) character to sort in descending order.
 
groupBy:Boolean (default = null) — the criteria for grouping the nodes, using the format of flare.util.Sort. The input can either be a string with a single property name, or an array of property names. Items are sorted in ascending order by default, prefix a property name with a "-" (minus) character to sort in descending order.
 
ignoreExistingEdges:* (default = false) — if false (the default), this method will not create a new edge if one already exists between two nodes. If true, new edges will be created regardless.
fromArray()method 
public static function fromArray(a:Array):Data

Creates a new Data instance from an array of tuples. The object in the array will become the data objects for NodeSprites.

Parameters
a:Array — an Array of data objects

Returns
Data — a new Data instance, with NodeSprites populated with the input data.
fromDataSet()method 
public static function fromDataSet(ds:DataSet):Data

Creates a new Data instance from a data set.

Parameters
ds:DataSet — a DataSet to visualize. For example, this data set may be loaded using a data converter in the flare.data library.

Returns
Data — a new Data instance, with NodeSprites and EdgeSprites populated with the input data.
group()method 
public function group(name:String):DataList

Retrieves the data group with the given name.

Parameters
name:String — the name of the group

Returns
DataList — the data group
newEdge()method 
protected function newEdge(s:NodeSprite, t:NodeSprite, d:Boolean, data:Object):EdgeSprite

Internal function for creating a new edge. Creates an EdgeSprite, sets its data property, and applies default values.

Parameters
s:NodeSprite — the source node
 
t:NodeSprite — the target node
 
d:Boolean — the edge's directedness
 
data:Object — the new edge's data property

Returns
EdgeSprite — the newly created node
newNode()method 
protected function newNode(data:Object):NodeSprite

Internal function for creating a new node. Creates a NodeSprite, sets its data property, and applies default values.

Parameters
data:Object — the new node's data property

Returns
NodeSprite — the newly created node
remove()method 
public function remove(d:DataSprite):Boolean

Removes a DataSprite (node or edge) from this data collection.

Parameters
d:DataSprite — the DataSprite to remove

Returns
Boolean — true if removed successfully, false if not found
removeEdge()method 
public function removeEdge(e:EdgeSprite):Boolean

Removes an edge from this data set. The nodes connected to this edge will have the edge removed from their edge lists.

Parameters
e:EdgeSprite — the edge to remove

Returns
Boolean
removeGroup()method 
public function removeGroup(name:String):DataList

Removes a data group. An error will be thrown if the caller attempts to remove the groups "nodes" or "edges".

Parameters
name:String — the name of the group to remove

Returns
DataList — the removed data group
removeNode()method 
public function removeNode(n:NodeSprite):Boolean

Removes a node from this data set. All edges incident on this node will also be removed. If the node is not found in this data set, the method returns null.

Parameters
n:NodeSprite — the node to remove

Returns
Boolean
visit()method 
public function visit(v:Function, group:String = null, filter:Boolean = null, reverse:* = false):Boolean

Visit items, invoking a function on all visited elements.

Parameters
v:Function — the function to invoke on each element. If the function return true, the visitation is ended with an early exit
 
group:String (default = null) — the data group to visit (e.g., NODES or EDGES). If this value is null, both nodes and edges will be visited.
 
filter:Boolean (default = null) — an optional predicate function indicating which elements should be visited. Only items for which this function returns true will be visited.
 
reverse:* (default = false) — an optional parameter indicating if the visitation traversal should be done in reverse (the default is false).

Returns
Boolean — true if the visitation was interrupted with an early exit
Event detail
addevent 
Event object type: flare.vis.events.DataEvent

removeevent  
Event object type: flare.vis.events.DataEvent

Constant detail
EDGESconstant
public static const EDGES:String = "edges"

Constant indicating the edges in a Data object.

NODESconstant 
public static const NODES:String = "nodes"

Constant indicating the nodes in a Data object.