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

Class aperture.Mapping

A Mapping is responsible for mapping value(s) for a visual property as a constant (asValue) or from a data source, using an optional map key. Layer Mappings are accessed and defined by calling

Method Summary

Method Detail

  • {aperture.Mapping} asValue(value)
    Maps this property to a constant value. The value may be a string, number, boolean array, or object. A mapping to a constant value is an alternative to mapping do data using from.
    {Object} value
    The value to bind to this property.
    {aperture.Mapping} this mapping object
  • filter(filter)
    Applies a filter to this visual property, or clears all filters if no filter is supplied. A filter is applied after a visual value is calculated using the values passed into from, asValue, and using. Filters can be used to alter the visual value, for example, making a color brighter or overriding the stroke with on certain conditions. A filter is a function in the form:
    function( value, etc... ) {
        // value:  the visual value to be modified by the filter
        // etc:    other values (such as indexes) passed in by the renderer
        // this:   the data item to which this value pertains
        return modifiedValue;
    {Function} filter
    A filter function in the form specified above, or nothing / null if clearing.
  • filterWithout(filter)
    Removes a pre-existing filter, leaving any other filters intact.
    {Function} filter
    A filter function to find and remove.
  • filteredValue(value, context, index)
  • {aperture.Mapping} from(source)
    Maps the graphic property from a source of values from the data object. A visual property may be mapped using one or more of the following constructs:
    • Field: A visual property may be mapped to a given field in the data.
    • Function: A visual property may be mapped to a function that will be called and provided the data item and expected to return a value for the property.
    // Map x to a field in the data object called 'xCoord''x').from('xCoord');
    // Map label to the value returned by the given function'label').from( function() { return 'Name: ' +; } );
    // Map label to the value returned by the given data object's prototype function'label').from( MyDataType.prototype.getName );
    // Map x to a sequence of values and count to a static value of 20'x').from('xCoord[]');
    // Map y to a function and count to the length of the array field 'points''y').from( function(data, index) { return points[index].y; } );'count').from('points.length');
    {String|Function} source
    the source of the data to map the graphic property. May be a function that maps a given data object to the desired source data in the form function(dataObject), or may be a data object field name in the form 'a.b.c' where the data will be sourced from dataObject.a.b.c. The length of an array field may be mapped using 'fieldName.length'.
    {aperture.Mapping} this mapping object
  • {aperture.Mapping} only()
    Specifies that this mapping should not inherit from parent mappings.
    {aperture.Mapping} this mapping object
  • Provides a codified representational key for mapping between source data and the graphic property via a MapKey object. A MapKey object encapsulates the function of mapping from data value to graphic representation and the information necessary to express that mapping visually in a legend. Map keys can be created from Range objects, which describe the data range for a variable. A map key may be combined with a constant, field, or function provided data value source, providing the mapping from a variable source to visual property value for each data item, subject to any final filtering. The map key object will be used to translate the data value to an appropriate value for the visual property. For example, it may map a numeric data value to a color. Calling this function without an argument returns the current map key, if any.
    {aperture.MapKey} mapKey
    The map key object to use in mapping data values to graphic property values. Passing in null removes any existing key, leaving the source value untransformed, subject to any final filtering.
    {aperture.Mapping|aperture.MapKey} this mapping object if setting the value, else the map key if getting.
  • {Object} value(value, context, index)
    Maps a raw value by transforming it and applying filters, returning a visual property value.
    {Object} value
    The source value to map.
    {Object} context Optional
    The optional context to supply to any filters. If omitted the value of this in the filter call will be the Mapping instance.
    {Array} index Optional
    Optional indices to pass to the filters.
    {Object} A transformed and filtered value.
  • valueFor(dataItem, index)
    Retrieves the visual property value for the given dataItem and optional indices.
    {Object} dataItem
    The data object to retrieve a value for, which will be the value of this if evaluation involves calling a from and / or filterfunction.
    {Array} index Optional
    An optional array of indices