style
Named, user-editable styles for plots, shapes, fills and levels (ChartDeck extra).
#Functions
#style.boxfunction
A named box style: box.new takes it with { look: … }, and the member restyles every drawing that uses it at once.
style.box(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const st = style.box("Boxs")Since ChartScript 1
#style.cellfunction
A named cell style: table.cell takes it with { look: … }, and the member restyles every drawing that uses it at once.
style.cell(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const st = style.cell("Cells")Since ChartScript 1
#style.fillfunction
A named fill style (colour, opacity).
style.fill(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const fs = style.fill("Band", { color: color.accent, opacity: 20 })
const a = plot(high)
const b = plot(low)
fill(a, b, { look: fs })Since ChartScript 1
#style.labelfunction
A named label style: label.new takes it with { look: … }, and the member restyles every drawing that uses it at once.
style.label(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const st = style.label("Labels")Since ChartScript 1
#style.linefunction
A named line style (colour, width, dash, cap, opacity); levels and plots take it with { look: … }.
style.line(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const lv = style.line("Levels", { color: color.muted, width: 1, dash: dash.dotted })
hline(50, "Mid", { look: lv })Since ChartScript 1
#style.markerfunction
A named marker style for plotshape / plotchar (shape, size, colour, text).
style.marker(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const mk = style.marker("Signals", { size: size.small, color: color.up })
plotshape(close > open, "Up", { look: mk })Since ChartScript 1
#style.plotfunction
A named plot style (colour, width, dash, plot type, area opacity); plots take it with { look: … }.
style.plot(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const lk = style.plot("Averages", { width: 2 })
plot(ta.sma(close, 20), "SMA", { look: lk })Since ChartScript 1
#style.tablefunction
A named table style: table.new takes it with { look: … }, and the member restyles every drawing that uses it at once.
style.table(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const st = style.table("Tables")Since ChartScript 1
#style.textfunction
A named text style (size, font, weight, italic, colour, halo, background, padding, wrap ...).
style.text(title: const string, values: const T, …): string| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown on the Style tab. |
values | const T | property: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins. |
Returns string.
Example
const tx = style.text("Labels", { size: size.pt(9), weight: 600 })Since ChartScript 1
#style.variantfunction
A variant of a style (bull / bear colours ...): each variant is a user swatch; a call picks it with { variant: … }.
style.variant(look: const string, name: const string, values: const T, …)| Parameter | Type | Description |
|---|---|---|
look | const string | The style. |
name | const string | The variant name (letters, digits, _). |
values | const T | property: value pairs in an options object. |
Example
const lv = style.line("Levels", { color: color.muted })
style.variant(lv, "bull", { color: color.up })
hline(70, "Top", { look: lv, variant: "bull" })Since ChartScript 1