Class: BaseTwoPoint

CIQ.Drawing. BaseTwoPoint


new BaseTwoPoint()

Base class for drawings that require two mouse clicks. Override as required.

Methods


<static> CIQ.Drawing#highlight(highlighted)

Returns the highlighted state. Set this.highlighted to the highlight state. For simple drawings the highlighted state is just true or false. For complex drawings with pivot points for instance, the highlighted state may have more than two states. Whenever the highlighted state changes a draw() event will be triggered.

Parameters:
Name Type Description
highlighted Boolean

True to highlight the drawing, false to unhighlight


<static> CIQ.Drawing#setPoint(point, x, y [, chart])

Sets the internal properties of the drawing points where x is a tick or a date and y is a value.

Parameters:
Name Type Argument Description
point number

index to point to be converted (0,1)

x number | string

index of bar in dataSet (tick) or date of tick (string form)

y number

price

chart CIQ.ChartEngine.Chart <optional>

Optional chart object

Since:
  • 04-2015


accidentalClick(tick, value)

Any two-point drawing that results in a drawing that is less than 10 pixels can safely be assumed to be an accidental click. Such drawings are so small that they are difficult to highlight and delete, so we won't allow them.

Note: it is very important to use pixelFromValueAdjusted() rather than pixelFromPrice(). This will ensure that saved drawings always render correctly when a chart is adjusted or transformed for display

Parameters:
Name Type Description
tick number

Tick in the dataSet.

value number

Value at position.


adjust()

Default adjust function for BaseTwoPoint drawings


boxIntersection(tick, value, box)

Determine whether the tick/value lies within the theoretical box outlined by this drawing's two points.

Parameters:
Name Type Description
tick number

Tick in the dataSet.

value number

Value at position.

box object

x0, y0, x1, y1, r representing an area around the cursor, including the radius.

Returns:

True if box intersects the drawing.

Type
boolean

click(context, tick, value)

Value will be the actual underlying, unadjusted value for the drawing. Any adjustments or transformations are reversed out by the kernel. Internally, drawings should store their raw data (date and value) so that they can be rendered on charts with different layouts, axis, etc

Parameters:
Name Type Description
context CanvasRenderingContext2D

Canvas context on which to render.

tick number

Tick in the dataSet.

value number

Value at position.


lineIntersection(tick, value, box, type [, p0] [, p1] [, isPixels])

Intersection is based on a hypothetical box that follows a user's mouse or finger. An intersection occurs when the box crosses over the drawing. The type should be "segment", "ray" or "line" depending on whether the drawing extends infinitely in any or both directions. Radius determines the size of the box in pixels and is determined by the kernel depending on the user interface (mouse, touch, etc.).

Parameters:
Name Type Argument Description
tick number

Tick in the dataSet.

value number

Value at the cursor position.

box object

x0, y0, x1, y1, r representing an area around the cursor, including the radius.

type string

Determines how the line should be treated (as segment, ray, or line) when finding an intersection.

p0 Array.<number> <optional>

The x/y coordinates of the first endpoint of the line that is tested for intersection with box.

p1 Array.<number> <optional>

The x/y coordinates of the second endpoint of the line that is tested for intersection with box.

isPixels boolean <optional>

Indicates that box values are in pixel values.

Returns:

True if the line intersects the box; otherwise, false.

Type
boolean

measure()

Default measure function for BaseTwoPoint drawings


move(context, tick, value)

Default move function for BaseTwoPoint drawings

Parameters:
Name Type Description
context CanvasRenderingContext2D

Canvas context on which to render.

tick number

Tick in the dataSet.

value number

Value at position.