legend
Items the script shows in its legend row after its name: text, colour keys and badges, from the newest bar.
#Functions
#legend.badgefunction
Shows a small outlined badge at the end of the legend row, such as "Model estimate".
legend.badge(text: string, { tooltip?: string = "", warn?: bool = false })| Parameter | Type | Description |
|---|---|---|
text | string | The badge text. |
tooltip | stringdefault "" | Text shown under the pointer. |
warn | booldefault false | true = in the warning colour. |
Example
legend.badge("Model estimate", "Model estimate, not exchange data.")Since ChartScript 1
#legend.infofunction
Shows text in the legend row after the script name (from the newest bar). At most 24 items a script.
legend.info(text: string, { tooltip?: string = "", warn?: bool = false, priority?: int = 2 })| Parameter | Type | Description |
|---|---|---|
text | string | The text (at most 120 characters). |
tooltip | stringdefault "" | Text shown under the pointer. |
warn | booldefault false | true = in the warning colour. |
priority | intdefault 2 | 1 = always kept; 2; 3 = dropped first when the row is too narrow. |
Example
if (barstate.islast) {
legend.info("updated " + str.format_time(timenow, "HH:mm") + " UTC")
}Since ChartScript 1
#legend.keyfunction
Shows a colour key in the legend row: a swatch and its text.
legend.key(text: string, { color?: color = na, palette?: string = "", dashed?: bool = false, group?: string = "", priority?: int = 3 })| Parameter | Type | Description |
|---|---|---|
text | string | The text. |
color | colordefault na | The swatch colour. |
palette | stringdefault "" | A heatmap palette (heatmap.palette_*): the swatch shows its gradient. |
dashed | booldefault false | true = a dashed swatch. |
group | stringdefault "" | Keys with the same group are dropped together on a narrow row. |
priority | intdefault 3 | 1 = always kept; 3 = dropped first. |
Example
legend.key("longs", color.up)
legend.key("$1M+ per level", na, heatmap.palette_heat)Since ChartScript 1