| Package | flare.vis.data |
| Class | public class Data |
| Inheritance | Data flash.events.EventDispatcher |
| Subclasses | Tree |
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
| Property | Defined 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 | ||
| Property | Defined 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 | ||
| Method | Defined 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 | ||
|
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 | ||
|
[static]
Creates a new Data instance from an array of tuples.
| Data | ||
|
[static]
Creates a new Data instance from a data set.
| Data | ||
|
Retrieves the data group with the given name.
| Data | ||
|
remove(d:DataSprite):Boolean
Removes a DataSprite (node or edge) from this data collection.
| Data | ||
|
removeEdge(e:EdgeSprite):Boolean
Removes an edge from this data set.
| Data | ||
|
removeGroup(name:String):DataList
Removes a data group.
| Data | ||
|
removeNode(n:NodeSprite):Boolean
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 | ||
| Method | Defined by | ||
|---|---|---|---|
|
Internal function for creating a new edge.
| Data | ||
|
newNode(data:Object):NodeSprite
Internal function for creating a new node.
| Data | ||
| Constant | Defined 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 | ||
| directedEdges | property |
public var directedEdges:BooleanThe default directedness of new edges.
| _edges | property |
protected var _edges:DataListInternal list of EdgeSprites.
| edges | property |
edges:DataList [read-only]The collection of EdgeSprites.
Implementation public function get edges():DataList
| _groups | property |
protected var _groups:ObjectInternal set of data groups.
| length | property |
length:int [read-only]The total number of items (nodes and edges) in the data.
Implementation public function get length():int
| _nodes | property |
protected var _nodes:DataListInternal list of NodeSprites.
| nodes | property |
nodes:DataList [read-only]The collection of NodeSprites.
Implementation public function get nodes():DataList
| _root | property |
protected var _root:NodeSprite = nullThe root node of the spanning tree.
| root | property |
root:NodeSprite [read-write]The root node of the spanning tree.
Implementation public function get root():NodeSprite
public function set root(value:NodeSprite):void
| _span | property |
protected var _span:TreeBuilderThe spanning tree constructor class.
| _tree | property |
protected var _tree:Tree = nullThe the spanning tree.
| tree | property |
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.
public function get tree():Tree
public function set tree(value:Tree):void
| treeEdgeWeight | property |
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
public function get treeEdgeWeight():Function
public function set treeEdgeWeight(value:Function):void
| treePolicy | property |
treePolicy:String [read-write]The spanning tree creation policy.
Implementation public function get treePolicy():String
public function set treePolicy(value:String):void
See also
| Data | () | constructor |
public function Data(directedEdges:Boolean = false)Creates a new Data instance.
ParametersdirectedEdges:Boolean (default = false) — the default directedness of new edges
|
| addEdge | () | method |
public function addEdge(e:EdgeSprite):EdgeSpriteAdd 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.
Parameterse:EdgeSprite — the EdgeSprite to add
|
EdgeSprite —
the newly added EdgeSprite
|
| addEdgeFor | () | method |
public function addEdgeFor(source:NodeSprite, target:NodeSprite, directed:Object = null, data:Object = null):EdgeSpriteCreates a new edge between the given nodes and adds it to the data collection.
Parameterssource: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.
|
EdgeSprite —
the newly added EdgeSprite
|
| addGroup | () | method |
public function addGroup(name:String, group:DataList = null):DataListAdds 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.
Parametersname: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.
|
DataList —
the added data group
|
| addNode | () | method |
public function addNode(d:Object = null):NodeSpriteAdds a node to this data collection.
Parametersd: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.
|
NodeSprite —
the newly added NodeSprite
|
| clear | () | method |
public function clear():voidClears this data set, removing all nodes and edges.
| contains | () | method |
public function contains(d:DataSprite):BooleanIndicates if this Data object contains the input DataSprite.
Parametersd:DataSprite — the DataSprite to check for containment
|
Boolean — true if the sprite is in this data collection, false
otherwise.
|
| createEdges | () | method |
public function createEdges(sortBy:* = null, groupBy:Boolean = null, ignoreExistingEdges:* = false):voidGenerates 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.
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):DataCreates a new Data instance from an array of tuples. The object in the array will become the data objects for NodeSprites.
Parametersa:Array — an Array of data objects
|
Data —
a new Data instance, with NodeSprites populated with the
input data.
|
| fromDataSet | () | method |
public static function fromDataSet(ds:DataSet):DataCreates a new Data instance from a data set.
Parametersds:DataSet — a DataSet to visualize. For example, this data set may be
loaded using a data converter in the flare.data library.
|
Data —
a new Data instance, with NodeSprites and EdgeSprites
populated with the input data.
|
| group | () | method |
public function group(name:String):DataListRetrieves the data group with the given name.
Parametersname:String — the name of the group
|
DataList —
the data group
|
| newEdge | () | method |
protected function newEdge(s:NodeSprite, t:NodeSprite, d:Boolean, data:Object):EdgeSpriteInternal function for creating a new edge. Creates an EdgeSprite, sets its data property, and applies default values.
Parameterss:NodeSprite — the source node
|
|
t:NodeSprite — the target node
|
|
d:Boolean — the edge's directedness
|
|
data:Object — the new edge's data property
|
EdgeSprite —
the newly created node
|
| newNode | () | method |
protected function newNode(data:Object):NodeSpriteInternal function for creating a new node. Creates a NodeSprite, sets its data property, and applies default values.
Parametersdata:Object — the new node's data property
|
NodeSprite —
the newly created node
|
| remove | () | method |
public function remove(d:DataSprite):BooleanRemoves a DataSprite (node or edge) from this data collection.
Parametersd:DataSprite — the DataSprite to remove
|
Boolean — true if removed successfully, false if not found
|
| removeEdge | () | method |
public function removeEdge(e:EdgeSprite):BooleanRemoves an edge from this data set. The nodes connected to this edge will have the edge removed from their edge lists.
Parameterse:EdgeSprite — the edge to remove
|
Boolean |
| removeGroup | () | method |
public function removeGroup(name:String):DataListRemoves a data group. An error will be thrown if the caller attempts to remove the groups "nodes" or "edges".
Parametersname:String — the name of the group to remove
|
DataList —
the removed data group
|
| removeNode | () | method |
public function removeNode(n:NodeSprite):BooleanRemoves 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.
Parametersn:NodeSprite — the node to remove
|
Boolean |
| visit | () | method |
public function visit(v:Function, group:String = null, filter:Boolean = null, reverse:* = false):BooleanVisit items, invoking a function on all visited elements.
Parametersv: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).
|
Boolean — true if the visitation was interrupted with an early exit
|
| add | event |
| remove | event |
| EDGES | constant |
public static const EDGES:String = "edges"Constant indicating the edges in a Data object.
| NODES | constant |
public static const NODES:String = "nodes"Constant indicating the nodes in a Data object.