public method host:execute("drawLabel1", ...)
Brief
Creates or replaces a label (advanced version).
Declaration | ||
|
Parameters | |||||||||
id |
Integer. The label identifier. |
||||||||
x |
Double. X-coordinate of the label. The meaning of the value depends on the value of |
||||||||
xType |
Integer. The parameter can be one of the following values:
|
||||||||
y |
Double. Y-coordinate of the label. The meaning of the value depends on the value of |
||||||||
yType |
Integer. The parameter can be one of the following values:
|
||||||||
halign |
Integer. The horizontal alignment of the label agains the points specified by x and y coordinates. The horizontal alignment. Can be
|
||||||||
valign |
Integer. The vertical alignment of the label against the points specified by x and y coordinates. Can be
|
||||||||
font |
String. The font previously created using |
||||||||
color |
Integer. The color of the label. You can either create your own color using |
||||||||
text |
The label text. |
Details
Note: This function is optional and may be not supported by the host application.
To remove the line use the host:execute("removeLabel");
method.
The method can be used in indicators only.
Example: Create custom labels [hide]
function Init() indicator:name("testlabel"); indicator:requiredSource(core.Bar); indicator:type(core.Indicator); end local font; local font2; local source; function Prepare() source = instance.source; instance:name(profile:id()); font = core.host:execute("createFont", "Courier", 10, true, false); font2 = core.host:execute("createFont", "Wingdings", 10, false, false); end function Update(period, mode) if source:size() > 0 and period == source:size() - 1 then local id = 1; local min, max; min, max = mathex.minmax(source, source:first(), source:size() - 1); core.host:execute("drawLabel1", id, 0, core.CR_LEFT, 0, core.CR_TOP, core.H_Right, core.V_Bottom, font, core.rgb(255, 0, 0), "top-left"); id = id + 1; core.host:execute("drawLabel1", id, 0, core.CR_LEFT, 0, core.CR_BOTTOM, core.H_Right, core.V_Top, font, core.rgb(0, 255, 0), "bottom-left"); id = id + 1; core.host:execute("drawLabel1", id, 0, core.CR_RIGHT, 0, core.CR_TOP, core.H_Left, core.V_Bottom, font, core.rgb(0, 0, 255), "top-right"); id = id + 1; core.host:execute("drawLabel1", id, 0, core.CR_RIGHT, 0, core.CR_BOTTOM, core.H_Left, core.V_Top, font, core.rgb(0, 255, 255), "right-bottom"); id = id + 1; core.host:execute("drawLabel1", id, 0, core.CR_CENTER, 0, core.CR_CENTER, core.H_Center, core.V_Center, font, core.rgb(0, 255, 255), "center"); id = id + 1; core.host:execute("drawLabel1", id + 5, 0, core.CR_CENTER, min, core.CR_CHART, core.H_Center, core.V_Bottom, font2, core.rgb(0, 255, 255), "\225"); id = id + 1; core.host:execute("drawLabel1", id + 5, 0, core.CR_CENTER, max, core.CR_CHART, core.H_Center, core.V_Top, font2, core.rgb(0, 255, 255), "\226"); end end function ReleaseInstance() core.host:execute("deleteFont", font); core.host:execute("deleteFont", font2); end