DataCursor
Extends:
The DataCursor class is used to add data cursors to plots. It works with plots added to Graph and World objects.
Constructor Summary
Public Constructor | ||
public |
constructor(opts: object) |
Member Summary
Public Members | ||
public |
Object that contains info about the closest point to the cursor. |
|
public |
Sets the color of the data cursor box. |
|
public |
Updates the data cursor every frame. |
|
public |
Sets the cursor that appears when hovering a point in a plot. |
|
public |
Sets the radius of the cursor. |
|
public |
Flag for allowing the element to be dragged around. |
|
public |
plots: [Plot] Array with Plot elements that can have data cursors. |
Method Summary
Public Methods | ||
public |
add(args: ...*) |
|
public |
remove(args: ...*) |
Private Methods | ||
private |
draw() Draws the data cursor. |
|
private |
Tests if the mouse is over any plot. |
|
private |
isMouseOverPlot(plot: *): * Determines which is the closest point to the pointer. |
Inherited Summary
From class WorldElement | ||
public |
Sets the color in HEX format of the element. |
|
public |
Sets the cursor style when the mouse is over the element. |
|
public |
Flag for enabling or diabling this element. |
|
public |
Flag set when the element is being dragged around. |
|
public |
Sets the font of the element. |
|
public |
Sets the current height of the element. |
|
public |
Flag for allowing the element to be dragged around. |
|
public |
Sets the move style of the element. |
|
public |
Flag set when the mouse is over the element. |
|
public |
Sets a callback function for when the element is dragged around. |
|
public |
Sets the position of the element. |
|
public |
Sets the renderer used for the element. |
|
public |
Sets the rotation of the element. |
|
public |
A copy of the z-index value is stored here. |
|
public |
Sets the drawing scale of the element. |
|
public |
Flag for determining if the element will be a top-most element when dragged around. |
|
public |
Flag used to determine if an object is a child of WorldElement. |
|
public |
Sets the current width of the element. |
|
public |
Sets the world where this element is found. |
|
public |
Sets the z-index of the element. |
|
public |
addPosition(x: number, y: number) Adds the provided coordinates to the position. |
|
public |
Sets if the element is draggable. |
|
public |
Function called when the mouse moves to check if the pointer is over the element. |
|
public |
Sets the color in HEX format of the element. |
|
public |
setPosition(x: number, y: number) Sets the position of the element. |
|
public |
Sets the scale of the element. |
|
public |
Sets the z-index of the element. |
|
private |
resize() Function called when the canvas gets resized. |
|
private |
Sets the world object where element will be drawn. |
|
private |
Sets the element as a topmost element. |
Public Constructors
public constructor(opts: object) source
Override:
WorldElement#constructorParams:
Name | Type | Attribute | Description |
opts | object |
|
Object that contains valid DataCursor properties with values. Their values will be assigned at the end of the constructor. If an invalid property is passed then the value will be ignored. |
Public Members
public closest: object source
Object that contains info about the closest point to the cursor.
Properties:
Name | Type | Attribute | Description |
Squared | distance | distance to the closest point. |
|
-x | px | coordinate in pixels, referenced to the main axis. |
|
-y | py | coordinate in pixels, referenced to the main axis. |
|
Label | label | with the -x and -y coordinates to be displayed in the data cursor. |
|
Plot's | color | color. |
public color: object source
Sets the color of the data cursor box. The color must have the format as in BOX_COLORS. The default value is BOX_COLORS.BLUE.
Override:
WorldElement#colorpublic cursor: string source
Sets the cursor that appears when hovering a point in a plot.
Override:
WorldElement#cursorpublic isDraggable: boolean source
Flag for allowing the element to be dragged around. Must be set to true, in order for the cursor to be changed.
Override:
WorldElement#isDraggablePublic Methods
public add(args: ...*) source
Params:
Name | Type | Attribute | Description |
args | ...* |
public remove(args: ...*) source
Params:
Name | Type | Attribute | Description |
args | ...* |
Private Methods
private isMouseOver(): boolean source
Tests if the mouse is over any plot.
Override:
WorldElement#isMouseOverprivate isMouseOverPlot(plot: *): * source
Determines which is the closest point to the pointer.
Params:
Name | Type | Attribute | Description |
plot | * |
Return:
* |