BaseShape
Direct Subclass:
Indirect Subclass:
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
- Matrix
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: Object) |
|
Method Summary
| Public Methods | ||
| public |
describe(datum: *, x: *): *[] Interface method that returns a value or description for salient features of the shape at the given x-coordinate (in time). |
|
| public |
destroy() Destroy the shape and clean references. |
|
| public |
Interface method called by |
|
| 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 describe(datum: *, x: *): *[] source
Interface method that returns a value or description for salient features of the shape at the given x-coordinate (in time).
The return value should be an array of objects each having properties "cy" (y-coord, i.e. underlying value of datum at or nearest to the given time), "cx" (x-coord in time of that datum) and optionally "unit" (unit of value as a string).
Params:
| Name | Type | Attribute | Description |
| datum | * | ||
| x | * |
Return:
| *[] |
public destroy() source
Destroy the shape and clean references. Interface method called from the layer.
public encache(datum: Object | Array): Object source
Interface method called by Layer~update, only for shapes with
entity type.
Called once for a given entity, to return any information derived from it that will be used subsequently when rendering. If this method returns a non-null object, then that object will be passed to the update method subsequently instead of the original entity datum. (If you want to retain access to the original entity, stash it in your cache object as well. Otherwise it may be GC'd if nobody else needs it.)
Return:
| Object | Cache data (opaque to caller) to pass to
|
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.
Params:
| Name | Type | Attribute | Description |
| renderingContext | Object | The |
|
| datum | Object | Array | The datum or cache associated with
the shape. If the shape has collection type, this will be the
single item from the dataset that the shape is dedicated to
displaying. If it has entity type, then this will be the
object previously returned from the shape's |