Class: module:BaseLayer

module:BaseLayer(data, axes, config, dependencies)

new module:BaseLayer(data, axes, config, dependencies)

Creates a layer using a configuration and data.
Parameters:
Name Type Description
data DataModel Instance of DataModel to be used. This DataModel instance serves as the data for a layer.
axes Object Axes instances to be used for rendering the layer. Axes are used for mapping data from value to px.
Properties
Name Type Description
x SimpleAxis X axis of the layer. Based on the type of variable it gets instance of BandAxis, TimeAxis, ContinuousAxis
y SimpleAxis X axis of the layer. Based on the type of variable it gets instance of BandAxis, TimeAxis, ContinuousAxis
color ColorAxis Axis for coloring a layer using color interpolators
shape ShapeAxis Axis for providing a shape
size SizeAxis Axis for determining size of a mark using size interpolator
config LayerConfig Configuration of the layer
dependencies Object Dependencies of the layer
Properties
Name Type Description
smartLabel SmartLabel Smartlabel singleton instance
Source:

Methods

(static) create() → {BaseLayer}

Creates a layer instance
Source:
Returns:
Instance of a layer
Type
BaseLayer

(static) defaultConfig() → {Object}

Default configuration of the layer. This configuration gets merged to the user passed configuration using a plolicy. Base layer only returns part of configuraion, any layer overridding base layer should return its own configuration.
Source:
Returns:
Default configuration
Type
Object

(static) defaultPolicy(conf, userConf) → {LayerConfig}

Policy defines how user config gets merged to default config. The default policy here does a deep copy operation. Any policy which does more than deep copying should define the policy as a static member.
Parameters:
Name Type Description
conf LayerConfig Configuration with which the user config will be merged
userConf LayerConfig Configuration given by the user
Source:
Returns:
Merged layer configuration
Type
LayerConfig

(static) formalName() → {string}

Determines a name for a layer. This name of the layer is used in the input data to refer to this layer. ``` .layer([ mark: 'bar', encoding: { ... } ]) ```
Source:
Returns:
name of layer
Type
string

alias(alias) → {BaseLayer|string}

Provides a alias for a layer. Like it's possible to have same layer (like bar) multiple times, but among multiple layers of same type if one layer has to be referred, alias is used. If no alias is given then `formalName` is set as the alias name. If used as setter
Parameters:
Name Type Description
alias string Name of the alias
Source:
Returns:
  • Instance of current base layer If used as getter
    Type
    BaseLayer
  • Alias of the current layer
    Type
    string

cachePoint(key, data) → {BarLayer}

Stores point in an object with key as the categorical value or temporal value
Parameters:
Name Type Description
key string categorical value or temporal value
data Object Information of the data point
Source:
Returns:
Instance of bar layer
Type
BarLayer

calculateDomainFromData(data, fieldsConfig) → {Array}

Calculates the domain from the data. It checks the type of field and calculates the domain based on that. For example, if it is a quantitative or temporal field, then it calculates the min and max from the data or if it is a categorical field then it gets all the values from the data of that field.
Parameters:
Name Type Description
data Array DataArray
fieldsConfig Object Configuration of fields
Source:
Returns:
Domain values array.
Type
Array

getDataDomain(encodingType) → {Object}

Returns the domain for the axis.
Parameters:
Name Type Description
encodingType string type of encoding x, y, etc.
Source:
Returns:
Axis domains
Type
Object

getNearestPoint(x, y) → {Object}

Gets the nearest point closest to the given x and y coordinate. If no nearest point is found, then it returns null.
Parameters:
Name Type Description
x number X Coordinate.
y number Y Coordinate.
Source:
Returns:
Information of the nearest point. ``` { // id property contains the field names and their corresponding values in a 2d array. This is the data // associated with the nearest point. id: // Example data: [['Origin'], ['USA']], dimensions: // Physical dimensions of the point. layerId: // Id of the layer instance. } ```
Type
Object

getNormalizedData(encodingType) → {Object}

Normalizes the transformed data and returns it.
Parameters:
Name Type Description
encodingType string type of encoding x, y, etc.
Source:
Returns:
Axis domains
Type
Object

getPlotElementsFromSet(set) → {Selection}

Returns the dom elements associated with the supplied set of row ids. Each element in the layer is mapped with a row of the datamodel. When given an array of row ids, it returns all the elements which is mapped with those row ids.
Parameters:
Name Type Description
set Array Array of row ids
Source:
Returns:
D3 Selection of dom elements.
Type
Selection

getPointsFromIdentifiers(identifiers, config) → {Array}

Returns the information of the marks corresponding to the supplied identifiers. Identifiers are a set of field names and their corresponding values in an array. It can also be an instance of datamodel. For example, ``` const identifiers = [ ['Origin', 'Cylinders'], ['USA', '8'] ]; const points = barLayer.getPointsFromIdentifiers(identifiers); ```
Parameters:
Name Type Description
identifiers Array | DataModel Identifiers of the marks.
config Object Optional configuration which describes how to get the information.
Properties
Name Type Description
getAllAttrs boolean If true, then returns all the information of the points, else returns only the positions of the points.
getBBox boolean If true, then returns the bounding box of all the marks.
Source:
Returns:
Array of points contains
Type
Array

getTransformedData(dataModel, config) → {Array.<Array>}

Returns the transformed data based on given transform type. It first gets the transform method from transform factory based on type of transform. It then calls the transform method with the data and passes the configuration parameters of transform such as groupBy, value field, etc.
Parameters:
Name Type Description
dataModel DataModel Instance of DataModel
config Object Configuration for transforming data
Source:
Returns:
Transformed data.
Type
Array.<Array>

id() → {string}

Returns the unique identifier of this layer. Id is auto generated during the creation proceess of a schema.
Source:
Returns:
id of the layer
Type
string

remove() → {BaseLayer}

Disposes the entire layer.
Source:
Returns:
Instance of layer.
Type
BaseLayer

render() → {BaseLayer}

Renders the layer
Source:
Returns:
Instance of the layer.
Type
BaseLayer

serialize() → {LayerConfig}

Serialize the schema. Merge config is used for serialization.
Source:
Returns:
Serialized schema
Type
LayerConfig