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) |
Method Summary
Public Methods | ||
public |
destroy() 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 |
|
public |
Interface method called by Layer when creating a shape. |
|
public |
Interface method called by |
|
public |
Interface method called by |
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 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'
).
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:
Name | Type | Attribute | Description |
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. |
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.
public render(renderingContext: Object): Element source
Interface method called by Layer~render
. Creates the DOM structure of
the shape.
Params:
Name | Type | Attribute | Description |
renderingContext | Object | the renderingContext of the layer which owns this shape. |
public update(renderingContext: Object, datum: Object | Array) source
Interface method called by Layer~update
. Updates the DOM structure of the shape.