3.9.7.1Drawing properties

Drawings can have the following properties. Each drawing must have a type and an array of points[]. The number of required points depends on the type of drawing: one for a horizontal line, two for a rectangle etc

Some properties are only applicable to some types of drawing (e.g. text, icon). Only the type and points[] are compulsory. Colours and other visual settings are optional, and have defaults. All colour values are HTML colour codes such as "red" or "#FF0000" or "rgba(255,0,0,0.5)".

Property

Description

type

Type of drawing, e.g. "lineSegment"

points[]

Array of points, each one consisting of a date and a value. For example: points: [{date: 1778056552000, value: 1.23456}]. For text and rectangle drawings, the points can be pixel co-ordinates (from the top-left of the chart), instead of time-price co-ordinates. For example: points: [{x:100, y:100}, {x:200, y:200}]. (Number of items required in the array depends on the type of drawing.)

style

Graphical style for the drawing, consisting of line and/or fill and/or text sub-objects depending on the type of drawing

style.line

Can contain the properties color, width, and lineStyle. The style of the line can be "solid", "dash", or "dot". For some types of drawing, such as lines, the style can also be any character from the Font Awesome font, in the form "icon-aaaa" where "aaaa" is the hex code of the character, such as "f0ab".

style.fill

Can contain a color property, specifying fill color

style.text

Can contain the properties color, fontFamily, fontSize, and fontStyle. See below for the types of drawing which accept text.

unselectable

If true, makes the drawing completely unselectable (and unmoveable, and undeletable). Defaults to false.

moveable

If true, allows the user to move the drawing. Defaults to false.

removable

If true, allows the user to delete the drawing. Defaults to false.

showInBackground

If true, the drawing is shown behind the bars on the chart, not in front of them. Defaults to false.

text

Text to display. See below for the types of drawing which accept text.

icon

Icon to display, as a hex code of a character from the Font Awesome character set, such as "f0ab"

iconColor

Colour for the icon

iconSize

Size, in pixels, for the icon

markerOffset

For the barMarker drawing type, offsets the position of the marker from the price by the specified number of pixels (negative for above, positive for below)

textAboveLine

Boolean value which positions text above the centre of the drawing (e.g. above a horizontal line or a bar marker) rather than below it. Defaults to false.