Home Manual Reference Source Repository
import BaseShape from 'waves-ui/src/shapes/base-shape.js'
public class | source

BaseShape

Is an abstract class or interface to be overriden in order to define new shapes. Shapes define the way a given datum should be rendered, they are the smallest unit of rendering into a timeline.

All the life cycle of Shape instances is handled into the Layer instance they are attach to. As a consequence, they should be mainly considered as private objects. The only place they should be interacted with is in Behavior definitions, to test which element of the shape is the target of the interaction and define the interaction according to that test.

Depending of its implementation a Shape can be used along with entity or collection data type. Some shapes are then created to use data considered as a single entity (Waveform, TracePath, Line), while others are defined to be used with data seen as a collection, each shape rendering a single entry of the collection. The shapes working with entity type data should therefore be used in an entity configured Layer. Note that if they are registered as "commonShape" in a collection type Layer, they will behave the exact same way. These kind of shapes are noted: "entity shape".

Available collection shapes:

  • Marker / Annotated Marker
  • Segment / Annotated Segment
  • Dot
  • TraceDots

Available entity shapes:

  • Line
  • Tick (for axis)
  • Waveform
  • TracePath

Constructor Summary

Public Constructor
public

constructor(options: Object)

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

Destroy the shape and clean references.

public

Interface method to override when extending this base class.

public

inArea(renderingContext: Object, datum: Object | Array, x1: Number, y1: Number, x2: Number, y2: Number): Boolean

Interface method to override called by Layer~getItemsInArea.

public

install(accessors: Object<String, function>)

Interface method called by Layer when creating a shape.

public

render(renderingContext: Object): Element

Interface method called by Layer~render.

public

update(renderingContext: Object, datum: Object | Array)

Interface method called by Layer~update.

Protected Methods
protected

Returns an object where keys are the accessors methods names to create and values are the default values for each given accessor.

protected

Returns the defaults for global configuration of the shape.

Public Constructors

public constructor(options: Object) source

Params:

NameTypeAttributeDescription
options Object

override default configuration

Public Members

public $el: Element source

public ns: String source

public params: Object source

Public Methods

public destroy() source

Destroy the shape and clean references. Interface method called from the layer.

public getClassName(): String source

Interface method to override when extending this base class. The method is called by the Layer~render method. Returns the name of the shape, used as a class in the element group (defaults to 'shape').

Return:

String

public inArea(renderingContext: Object, datum: Object | Array, x1: Number, y1: Number, x2: Number, y2: Number): Boolean source

Interface method to override called by Layer~getItemsInArea. Defines if the shape is considered to be the given area. Arguments are passed in pixel domain.

Params:

NameTypeAttributeDescription
renderingContext Object

the renderingContext of the layer which owns this shape.

datum Object | Array

The datum associated to the shape.

x1 Number

The x component of the top-left corner of the area to test.

y1 Number

The y component of the top-left corner of the area to test.

x2 Number

The x component of the bottom-right corner of the area to test.

y2 Number

The y component of the bottom-right corner of the area to test.

Return:

Boolean

Returns true if the is considered to be in the given area, false otherwise.

public install(accessors: Object<String, function>) source

Interface method called by Layer when creating a shape. Install the given accessors on the shape, overriding the default accessors.

Params:

NameTypeAttributeDescription
accessors Object<String, function>

public render(renderingContext: Object): Element source

Interface method called by Layer~render. Creates the DOM structure of the shape.

Params:

NameTypeAttributeDescription
renderingContext Object

the renderingContext of the layer which owns this shape.

Return:

Element

the DOM element to insert in the item's group.

public update(renderingContext: Object, datum: Object | Array) source

Interface method called by Layer~update. Updates the DOM structure of the shape.

Params:

NameTypeAttributeDescription
renderingContext Object

The renderingContext of the layer which owns this shape.

datum Object | Array

The datum associated to the shape.

Protected Methods

protected _getAccessorList(): Object source

Returns an object where keys are the accessors methods names to create and values are the default values for each given accessor.

Return:

Object

TODO:

  • rename ?

protected _getDefaults(): Object source

Returns the defaults for global configuration of the shape.

Return:

Object