Label
标签绘图的句柄。
静态方法
new
在图表上创建标签对象。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
point | series chart.Point | 指定标签位置的 chart.point 对象。 | |
text | series string | "" | 要在标签上显示的文本。 |
xloc | series Xloc | Xloc.BarIndex | x 位置类型:xloc.bar_index 或 xloc.bar_time。 |
yloc | series Yloc | Yloc.Price | y 位置类型:yloc.price 或 yloc.price_range。 |
color | series color | na | 标签的背景颜色。 |
style | series LabelStyle | LabelStyle.Down | 标签的样式。 |
text_color | series color | na | 标签文本的颜色。 |
size | series Size | Size.Normal | 标签的大小作为命名常量。 |
textalign | series TextHAlign | TextHAlign.Center | 文本对齐方式:TextHAlign.Center、TextHAlign.Left 或 TextHAlign.Right。 |
tooltip | series string | na | 将鼠标悬停在标签上时的工具提示文本。 |
text_font_family | series FontFamily | FontFamily.Default | 标签文本的字体系列。 |
force_overlay | const bool | false | 如果为 true,则标签将呈现在顶部。 |
text_formatting | const TextFormat | text.NONE | 文本格式选项。 |
返回: series Label
静态属性
all
返回一个数组,其中填充了脚本绘制的所有当前标签。
方法
copy
navi
Label.copy(id: series Label): series Label创建指定标签的拷贝并返回其 id。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要复制的标签。 |
返回: series Label
delete
navi
Label.delete(id: series Label)从图表中删除指定标签。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要删除的标签。 |
get_text
navi
Label.get_text(id: series Label): series string返回此标签的文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 从中获取文本的标签。 |
返回: series string
get_x
navi
Label.get_x(id: series Label): series int返回此标签位置的 UNIX 时间或 bar 索引(取决于最后设置的 xloc 值)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 从中获取 x 坐标的标签。 |
返回: series int
get_y
navi
Label.get_y(id: series Label): series float返回该标签位置的价格。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 从中获取 y 坐标的标签。 |
返回: series float
set_color
navi
Label.set_color(id: series Label, color: series color)设置此标签的颜色。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
color | series color | 新的背景颜色。 |
set_point
navi
Label.set_point(id: series Label, point: series chart.Point)使用 chart.point 对象设置此标签的位置。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
point | series chart.Point | 指定新位置的 chart.point 对象。 |
set_size
set_style
navi
Label.set_style(id: series Label, style: series LabelStyle)设置此标签的样式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
style | series LabelStyle | 新标签样式不变。 |
set_text
navi
Label.set_text(id: series Label, text: series string)设置此标签的文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
text | series string | 要显示的新文本。 |
set_text_font_family
navi
Label.set_text_font_family(
id: series Label,
text_font_family: series FontFamily
)设置此标签的字体系列。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
text_font_family | series FontFamily | 字体系列:FontFamily.Default 或 FontFamily.Monospace。 |
set_text_formatting
navi
Label.set_text_formatting(id: series Label, text_formatting: const TextFormat)设置此标签的文本格式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
text_formatting | const TextFormat | 文本格式选项。 |
set_textalign
navi
Label.set_textalign(id: series Label, textalign: series TextHAlign)设置此标签的文本对齐方式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
textalign | series TextHAlign | 文本对齐方式:TextHAlign.Center、TextHAlign.Left 或 TextHAlign.Right。 |
set_textcolor
navi
Label.set_textcolor(id: series Label, text_color: series color)设置此标签的文本颜色。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
text_color | series color | 新的文本颜色。 |
set_tooltip
navi
Label.set_tooltip(id: series Label, tooltip: series string)设置此标签的工具提示文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
tooltip | series string | 新的工具提示文本。 |
set_x
navi
Label.set_x(id: series Label, x: series int)设置此标签位置的 UNIX 时间或 bar 索引(取决于最后设置的 xloc 值)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
x | series int | 新的 x 坐标(bar 索引或 UNIX 时间)。 |
set_xloc
navi
Label.set_xloc(id: series Label, xloc: series Xloc)设置此标签的 x 位置类型。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
xloc | series Xloc | x 位置类型:xloc.bar_index 或 xloc.bar_time。 |
set_xy
navi
Label.set_xy(id: series Label, x: series int, y: series float)设置此标签位置的 x 和 y 坐标。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
x | series int | 新的 x 坐标(bar 索引或 UNIX 时间)。 | |
y | series float | 新的 y 坐标(价格)。 |
set_y
navi
Label.set_y(id: series Label, y: series float)设置该标签位置的价格。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
y | series float | 新的 y 坐标(价格)。 |
set_yloc
navi
Label.set_yloc(id: series Label, yloc: series Yloc)设置此标签的 y 位置类型。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | series Label | 要修改的标签。 | |
yloc | series Yloc | y 位置类型:yloc.price 或 yloc.price_range。 |