Class: Column

OM. Column

new Column(options)

This class represents a Column data set. The raw data can be
of any object type, as long as they are in a JavaScript array, with each
element representing a feature or row.

Two functions named keyGetter and valueGetter must be provided. Within
the function, 'this' will be pointing to an element of the raw data array.
keyGetter must return the key for the element, while valueGetter must return
the value for the element.

A number of convenience methods exist to provide such information as
min/max values and size of the Column data set.

An internal hashmap is created based on the keys and their values, to enable
fast retrieval of value by key.

The keyGetter and valueGetter methods are called with 'this' referencing the current
row of the Column.

Name Type Description
options Object

An object containing the properties and methods of a Column.
The object should contain the following properties:

  • data {Object[]}. Required. Array of objects containing at least a key and measure properties.
    There may be additional properties but the keyGetter() should return the key
    property's value and valueGetter() should return the measure property's value.

  • keyGetter {Function}. Required. A function which returns the
    key value for a data row. e.g. getStoreId.

  • valueGetter {Function}. Required. A function which returns the
    measure (or value column's) value for a data row. e.g. getStoreSales.

  • type {String}. The type ("number", "float", "double") of the measure, or value,
    column of a data row.

  • measureName {String}. Name of the measure column (e.g. "Measure" or "Revenue").

  • measureIndex {Number}. Index of the column in the data array which should be
    treated as the measure value.


An instance of OM.Column


A usage example:

var myData = {"type":"FeatureCollection",
        "geometry": {"type":"Point", "coordinates":[-96.85, 37.82]},
        "properties":{"YEAR":"1950", "MONTH":"5", "DAY":"19", "STATE":"KS", 
                      "FSCALE":"0", "INJURIES":"1", "FATALITIES":"1", "LOSS":"3", 
        "geometry": {"type":"Point", "coordinates":[-84.15, 33.03]},
        "properties":{"YEAR":"1950", "MONTH":"6", "DAY":"7", "STATE":"GA", 
                      "FSCALE":"1", "INJURIES":"3", "FATALITIES":"1", "LOSS":"3", 

 var propertyLoss = new OM.Column(
                    keyGetter:function(){return this._id;}, 
                    valueGetter: function() {return parseFloat(["LOSS"]);}



Gets the maximum value of this Column instance.


the maximum value of this measure



Gets the minimum value of this Column instance.


the minimum value of this measure



Return the number of rows in this Column data set.

getValueOfRow(key, returns)

An interface method for returning the column data of the specified
row key.

Name Type Description
key Object

the key column(s). This must be a literal object
containing a single property named 'key'. The value
for this property must be an array containing one
or more values comprising the actual key. For example
{key:["California", "Marin"]}

returns Object

the value; or null if no row matching the key
can be found.