Tour API Demos Download Tests
Aperture version 1.0
Generated by: JsDoc Toolkit 2.4.0

Class aperture.Layer

A layer represents a set of like graphical elements which are mapped in a spatial node. Layer is the abstract base class of all graphical layers. Layer is abstract and not to be constructed directly. See addLayer for an example of how to add layers to a vizlet. All layers observe the following mapping:

Mappings

Method Summary

Method Detail

  • TODO: implement. Adds to the logical set of all layer nodes, returning the set of added items.
    Parameters:
    {Array|Object} data
    the array of data objects, from which each node will be mapped. May be an array of data objects or a single data object, and may not be a data subselection function. If this layer already gets its data from a subselection function set through all or join, this function will fail.
    Returns:
    {aperture.Layer.NodeSet} the set of added layer nodes.
  • {aperture.Layer.NodeSet} all(data, idFunction)
    Returns the logical set of all layer nodes, or (re)declares it by providing source data for each node to be mapped from.
    Parameters:
    {Array|Object|Function} data
    the array of data objects, from which each node will be mapped. May be an array of data objects, a single data object, or a function that subselects data objects from each parent data object. If an array of data is given a graphic will be created for each item in the array. If the parent layer has more than one data item, data items will be rendered per parent data item.
    {Function|String} idFunction Optional
    optionally a function or field name that supplies the id for a data item to match items from one update to another. If a function is supplied it will be called with the item as a parameter. If not supplied, id functions will be remembered from previous calls to this method, but can be cleared by specifying null. If never supplied, a best guess is made using item.id for matching if found in the data set supplied, or exact object instances if not.
    Returns:
    {aperture.Layer.NodeSet} the logic set of all layer nodes.
  • join(data, idFunction)
    Merges in new data, returning the logical set of all layer nodes. This method differs from all only in that it compares the new data set to the old data set and if the same node is identified in both it will update the existing one rather than creating a new one. A common use case for joins is to animate transitions between data sets.
    Parameters:
    data
    idFunction
  • {aperture.Mapping} map(graphicProperty)
    Returns a Mapping for a given graphic property to map it from source values. Map is a key function in layers, responsible for the transformation of data into visuals. Mappings inherit from parent mappings in the layer hierarchy unless cleared or overridden.
    Parameters:
    {String} graphicProperty
    The graphic property to return a map for.
    Returns:
    {aperture.Mapping} A mapping for this property.
  • {aperture.Layer} mapAll(propertyValues)
    Takes an object and maps all properties as simple values.
    Parameters:
    {Object} propertyValues
    The object with property values to map.
    Returns:
    {aperture.Layer} This layer.
  • {Object} mappings()
    Returns an object with properties and their mappings.
    Returns:
    {Object} An object with properties and their mappings.
  • off(eventType, callback)
    Removes a registered callback(s) for the given event type.
    Parameters:
    {String} eventType
    the DOM event name corresponding to the event type to unregister
    {Function} callback Optional
    an optional callback function. If given this specific callback is removed from the event listeners on this layer. If omitted, all callbacks for this eventType are removed.
  • on(eventType, callback)
    Registers a callback function for a given event type on the visuals drawn by this layer. Valid event types include DOM mouse events plus some custom events:
    • click
    • dblclick
    • mousedown
    • mousemove
    • mouseout
    • mouseover
    • mouseup
    • touchstart
    • touchmove
    • touchend
    • touchcancel
    • drag
    • dragstart*
    • dragend*
    Returning a truthy value from a callback indicates that the event is consumed and should not be propogated further.

    *Note that registration for drag events will result in the drag handler being called for drag, dragstart, and dragend events, distinguishable by the eventType property of the Event object. Attempts to register for dragstart and dragend events individually will have no effect.
    Parameters:
    {String} eventType
    the DOM event name corresponding to the event type for which this callback will be registered
    {Function} callback
    the callback function that will be called when this event is triggered. The callback function will be called in the this-node of this layer. The function will be passed an object of type aperture.Layer.Event
  • parent()
    Returns the parent (if it exists) of this layer.
  • {aperture.Layer} remove()
    Removes a layer from its parent.
    Returns:
    {aperture.Layer} This layer.
  • {this} toBack()
    Pushes this layer to the back of its parent layer.
    Returns:
    {this} this layer
  • {this} toFront()
    Brings this layer to the front of its parent layer.
    Returns:
    {this} this layer
  • trigger(eventType, event)
    Fires the specified event to all handlers for the given event type.
    Parameters:
    {String} eventType
    the DOM event name corresponding to the event type to fire
    {aperture.Layer.Event} event
    the event object that will be broadcast to all listeners
  • vizlet()
    Returns the containing vizlet for this layer.