Plot
Extends:
The Plot class can be used to draw a line plot or a histogram on an axis. It is also possible to add markers on top of a line plot with information about the -x and -y values.
Constructor Summary
Public Constructor | ||
public |
constructor(opts: object) |
Member Summary
Public Members | ||
public |
When the plot is configured in histogram mode, the binWidth is the width of the bars in pixels. |
|
public |
Sets the maximum index to display. |
|
public |
Flag for drawing all points in the plot regardless if the point is outside the visible range of the plot. |
|
public |
Sets the label for the plot. |
|
public |
Sets the maximum amount of points the plot can have at a single time. |
|
public |
Sets the linewidth of the plot in pixels. |
|
public |
Sets the radius of the markers. |
|
public |
Array for storing the markers. |
|
public |
Array for storing the points. |
|
public |
Sets a flag for shading the area under the curve. |
|
public |
Sets the color of the shade. |
|
public |
Sets the type of plot. |
Method Summary
Public Methods | ||
public |
Adds a marker to the plot. |
|
public |
Adds a point to the plot. |
|
public |
clear() Deletes all points and markers. |
|
public |
getPoints(): any Returns the points array until the max Idx. |
|
public |
Calculates the amount of points that can be displayed, starting from 0. |
|
public |
Sets a label for the plot. |
Private Methods | ||
private |
draw() Main draw function for the Plot called by the World automatically. |
|
private |
Draw the markers. |
|
private |
drawPlot(p: array) Draw the plot. |
|
private |
drawShade(p: array) Shade the area under the curve. |
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 Plot 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 binWidth: number source
When the plot is configured in histogram mode, the binWidth is the width of the bars in pixels. Default value is 3.
public drawInvisiblePoints: boolean source
Flag for drawing all points in the plot regardless if the point is outside the visible range of the plot. Default value is false.
public label: string source
Sets the label for the plot. Only used when the plot is added to a Graph object. Default value is "".
Public Methods
public addMarker(x: number, y: number, args: object) source
Adds a marker to the plot.
Params:
Name | Type | Attribute | Description |
x | number | x coordinate of the marker to add. |
|
y | number | y coordinate of the marker to add. |
|
args | object | Object with other properties that a marker can have. |
|
args.label | string | Top label of the marker. |
|
args.lower_label | string | Bottom label of the marker. |
|
args.color | string | HEX color of the marker. Default value is the color of the plot. |
|
args.top | boolean | Flag for choosing if the labels will be drawn over the marker or below the marker. Default value is true. |
public getPoints(): any source
Returns the points array until the max Idx. Also converts every point to pixels and determines if the point is visible.
Return:
any | Array of points. |
public maxIdx(): number source
Calculates the amount of points that can be displayed, starting from 0.
public setLabel(label: string) source
Sets a label for the plot. Only used when the plot is added to a Graph object.
Params:
Name | Type | Attribute | Description |
label | string | Label for the plot. |
Private Methods
private drawPlot(p: array) source
Draw the plot.
Params:
Name | Type | Attribute | Description |
p | array | Array of precalculated points. |
private drawShade(p: array) source
Shade the area under the curve.
Params:
Name | Type | Attribute | Description |
p | array | Array of precalculated points. |