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

Class aperture.Set

A Set contains a collection of values/objects. Elements of the set can be added, removed, toggles, and checked for containment. Sets maintain a notion of converting between data objects (used by layers) and the contents of the set. For example, a set may contain city names and a way to extract the city name from a give data element. TODO The notion of converting from data->set contents could be extracted into a separate object. This object could be reused elsewhere and would make the Set simpler.

Class Summary
Constructor Attributes Constructor Name and Description
 

Method Summary

Class Detail

aperture.Set(id)
Parameters:
{String|Function} id Optional
An optional conversion directive that allows a set to convert data items to set contents. The conversion will be used for creating filter functions on calls to functions such as scale.

Method Detail

  • {boolean} add(object)
    Adds an element to the Set. If the set already contains the element it will not be added.
    Parameters:
    object
    the element to be added
    Returns:
    {boolean} true if the element is added, else undefined
  • {Array} clear()
    Clears the set leaving it empty.
    Returns:
    {Array} the array of removed elements.
  • {Function} constant(val)
    Creates a constant value filter function that can be used on a layer mapping (see aperture.Layer.map). The filter will use the given constant value in place of the mapped value for all elements within this set.
    Parameters:
    val
    Returns:
    {Function} A filter function that can be applied to a visual property mapping of a layer.
  • {boolean} contains(object)
    Determines whether a given element is contained in this set.
    Parameters:
    object
    the element to be checked
    Returns:
    {boolean} true if the element is in the set, false otherwise
  • {Function} filter(filter)
    Creates a filter function that can be used on a layer mapping (see aperture.Layer.map). The filter function supplied will be called with the visual property value to be transformed and returned, but only for data elements that are within this set.
    Parameters:
    {Function} filter
    The transformation to apply, in the form function( value ) {return xvalue;}
    Returns:
    {Function} A filter function that can be applied to a visual property mapping of a layer.
  • forEach(fn)
    Executes a function for each element in the set, where the arguments will be the value and its index, in that order.
    Parameters:
    fn
  • {object} get(index)
    Returns the set element at index.
    Parameters:
    index
    the integer index of the element to return
    Returns:
    {object} the element at index.
  • {Function} not()
    Creates an inverted view of the Set (its complement) specifically aimed at creating filter functions that apply when an element is not in the set. The returned set will have an inverted contains behavior and will create inverted filter functions. Changes to the set using methods such as add, remove, and clear will work on the core set, and do not exhibit inverted behavior.
    Returns:
    {Function} A filter function in the form function( value, layer, data, ... )
  • remove(object)
    Removes an item from the Set.
    Parameters:
    object
    the element to be removed
  • {Function} scale(amount)
    Creates a scaling filter function that can be used on a layer mapping (see aperture.Layer.map). The given amount will be used to scale the filtered numeric visual property value but only for data elements that are within this set.
    Parameters:
    {Number} amount
    A scaling factor to apply to the mapped visual property for data elements that are within this set.
    Returns:
    {Function} A filter function that can be applied to a visual property mapping of a layer.
  • {number} size()
    Returns the number of elements in the set.
    Returns:
    {number} the count of elements in the set.
  • {Array} toArray()
    Returns the set contents in a new array.
    Returns:
    {Array} the set as a new array.
  • toggle(object)
    Toggles the membership of a given element in the set. If the set contains the element it will be removed. If it does not contain the element, it will be added.
    Parameters:
    object
    the element to be toggled
  • {Object} translateData(data, etc)
    Given a data object and optional indices returns the element value that could be or is included in this set. For example, if this set contains city name strings and was given an id directive for how to extract a city name from a given data item, this function will do exactly that.
    Parameters:
    {Object} data
    The data item to translate
    {Array} etc Optional
    An optional set of indexes
    Returns:
    {Object} The element that would be contained in this Set given the id translation directive given on Set construction. If no id directive, returns the data object as given.