Class: Drawing

STX. Drawing


new Drawing()

Base class for Drawing Tools. Use stxInheritsFrom() to build a subclass for custom drawing tools. The name of the subclass should be STX.Drawing.yourname. Whenever STXChart.vectorType==yourname, then your drawing tool will be the one that is enabled when the user begins a drawing. Capitalization of yourname must be an exact match otherwise ther kernel will not be able to find your drawing tool.

Each of the STX.Drawing prototype functions may be overridden. To create a functioning drawing tool you must override the functions below that create alerts.

Drawing clicks are always delivered in adjusted price. That is, if a stock has experienced splits then the drawing will not display correctly on an unadjusted price chart unless this is considered during the rendering process. Follow the templates to assure correct rendering under both circumstances.

If no color is specified when building a drawing then color will be set to "auto" and the chart will automatically display white or black depending on the background.

Permanent drawings:
To make a drawing permanent set its permanent property to true once created.
Example:
drawingObject.permanent=true;

See Custom Drawing Tools for more details.

Classes

annotation
BaseTwoPoint
callout
channel
continuous
ellipse
fibarc
fibfan
fibonacci
fibtimezone
freeform
gartley
horizontal
line
measure
pitchfork
ray
rectangle
retracement
segment
shape
vertical

Members


dragToDraw

Set to true when need to hold mouse down to draw; set to false for click on/off draw

Example
STX.Drawing.prototype.dragToDraw=true;

Methods


abort(forceClear)

Is called to tell a drawing to abort itself. It should clean up any rendered objects such as DOM elements or toggle states. It does not need to clean up anything that it drew on the canvas.

Parameters:
Name Type Description
forceClear boolean

Indicates that the user explicitly has deleted the drawing (advanced usage)


adjust()

Called whenever periodicity changes so that drawings can adjust their rendering.


click(context, tick, value)

Called when a user clicks while drawing.

Parameters:
Name Type Description
context object

The canvas context

tick number

The tick in the dataSet

value number

The value (price) of the click

Returns:

Return true if the drawing is complete. Otherwise the kernel will continue accepting clicks.

Type
boolean

construct(stx, panel)

Initializes the drawing

Parameters:
Name Type Description
stx object

The chart object

panel object

The panel reference


intersected(tick, value, box))

Called to determine whether the drawing is intersected by either the tick/value (pointer location) or box (small box surrounding the pointer). For line based drawings, box should be checked. For area drawings (rectangles, circles) the point should be checked

Parameters:
Name Type Description
tick number

The tick in the dataSet representing the cursor point

value number

The value (price) representing the cursor point

box) object

x0,y0,x1,y1 representing an area around the cursor

Returns:

An object that contains information about the intersection. This object is passed back to STX.Drawing.reposition when repositioning the drawing. Return false or null if not intersected. Simply returning true will highlight the drawing.

Type
object

measure()

Should call this.stx.setMeasure() with the measurements of the drawing if supported


move()

Called when the user moves while creating a drawing.


pointIntersection(tick, value, box)

Returns true if the tick and value are inside the box

Parameters:
Name Type Description
tick number

The tick

value number

The value

box object

The box

Returns:

True if the tick and value are within the box

Type
boolean

reconstruct()

Reconstruct this drawing type from a serialization object


render()

Called to render the drawing


reposition(context, repositioner, tick, value)

Called when the user attempts to reposition a drawing. The repositioner is the latest provided by STX.Drawing.intersected and can be used to determine which aspect of the drawing is being repositioned. For instance, this object may indicate which point on the drawing was selected by the user. It might also contain the original coordinates of the point or anything else that is useful to render the drawing.

Parameters:
Name Type Description
context object

The canvas context

repositioner object

The repositioner object

tick number

Current tick in the dataSet for the mouse cursor

value number

Current value in the datSet for the mouse cursor


serialize()

Serialize a drawing into an object.