candlestick(spec: CandlestickSpec): stringcandlestick — 6.0.0
Signature
Executable examples
OHLC candlestick
candlestick({
width: 30,
height: 10,
data: [[0, 100, 112, 96, 108], [1, 108, 114, 102, 105]],
style: {
rising: { symbol: '+', color: 'ansiGreen' },
falling: { symbol: 'x', color: 'ansiRed' },
},
thresholds: [{ id: 'target', y: 110, color: 'ansiCyan' }],
});
▲
│ │
││ │
│━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
108┤+ x
105┤+ x
│+ │
│+ │
│+
││
││
└┬────────────────────────────┬▶
0 1
CandlestickSpec
Complete candlestick chart specification.
type CandlestickSpec = Readonly<{
/** Unique-X OHLC tuples satisfying `low <= open/close <= high`. */
data: readonly CandlestickDatum[];
/** Plot width in terminal columns. */
width?: number;
/** Plot height in terminal rows. */
height?: number;
/** Title rendered above the chart. */
title?: string;
/** Numeric X-axis configuration. */
xAxis?: XAxis<number>;
/** Numeric Y-axis configuration. */
yAxis?: YAxis;
/** Per-direction body colors and glyphs plus a wick glyph. */
style?: CandlestickStyle;
/** Named horizontal or vertical reference lines. */
thresholds?: readonly ChartThreshold<number>[];
/** Shared symbol overrides. `style` glyphs take precedence. */
symbols?: Symbols;
/** Logs out-of-bounds drawing attempts for diagnostics. */
debugMode?: boolean;
}>;data
Unique-X OHLC tuples satisfying low <= open/close <= high.
Related executable examples: OHLC candlestick
xAxis
Numeric X-axis configuration.
Related executable examples: OHLC candlestick
style
Per-direction body colors and glyphs plus a wick glyph.
Related executable examples: OHLC candlestick
thresholds
Named horizontal or vertical reference lines.
Related executable examples: OHLC candlestick
symbols
Shared symbol overrides. style glyphs take precedence.
Related executable examples: OHLC candlestick
debugMode
Logs out-of-bounds drawing attempts for diagnostics.
Related executable examples: OHLC candlestick
CandlestickStyle
Symbols and colors used to distinguish candle directions.
type CandlestickStyle = Readonly<{
/** One-column wick glyph. */
wick?: string;
/** Style used when close is greater than open. */
rising?: CandlestickMarkStyle;
/** Style used when close is less than open. */
falling?: CandlestickMarkStyle;
/** Style used when close equals open. */
unchanged?: CandlestickMarkStyle;
}>;rising
Style used when close is greater than open.
Related executable examples: OHLC candlestick
falling
Style used when close is less than open.
Related executable examples: OHLC candlestick
unchanged
Style used when close equals open.
Related executable examples: OHLC candlestick
CandlestickMarkStyle
Body style for one candlestick price direction.
type CandlestickMarkStyle = Readonly<{
/** One-column body glyph. */
symbol?: string;
/** ANSI color applied to the body and wick. */
color?: Color;
}>;color
ANSI color applied to the body and wick.
Related executable examples: OHLC candlestick
CandlestickSymbols
Shared candlestick glyph overrides.
type CandlestickSymbols = Readonly<{
/** One-column wick glyph. */
wick?: string;
/** One-column glyph used when close is greater than open. */
rising?: string;
/** One-column glyph used when close is less than open. */
falling?: string;
/** One-column glyph used when close equals open. */
unchanged?: string;
}>;rising
One-column glyph used when close is greater than open.
Related executable examples: OHLC candlestick
falling
One-column glyph used when close is less than open.
Related executable examples: OHLC candlestick
unchanged
One-column glyph used when close equals open.
Related executable examples: OHLC candlestick
XAxis
Structured X-axis configuration.
type XAxis = {
/** Scale kind. Defaults to the kind inferred from X values. */
scale?: XScale;
/** Explicit category order or continuous scale extent. */
domain?: XAxisDomain<X>;
/** Exact native tick values or an exact tick count of at least two. */
ticks?: number | readonly X[];
/** Axis label rendered outside tick labels. */
label?: string;
/** Formatter called with native X values. */
formatter?: AxisFormatter<X>;
/** Hides the axis line, ticks, labels, and axis label. */
hidden?: boolean;
/** Hides tick markers and labels while retaining the axis line. */
hideTicks?: boolean;
/** Handling for labels that do not fit the available width. */
labelCollision?: LabelCollisionPolicy;
/** ANSI color applied to the axis line, ticks, tick labels, and label. */
color?: Color;
};scale
Scale kind. Defaults to the kind inferred from X values.
Related executable examples: OHLC candlestick
domain
Explicit category order or continuous scale extent.
Related executable examples: OHLC candlestick
ticks
Exact native tick values or an exact tick count of at least two.
Related executable examples: OHLC candlestick
label
Axis label rendered outside tick labels.
Related executable examples: OHLC candlestick
formatter
Formatter called with native X values.
Related executable examples: OHLC candlestick
hidden
Hides the axis line, ticks, labels, and axis label.
Related executable examples: OHLC candlestick
hideTicks
Hides tick markers and labels while retaining the axis line.
Related executable examples: OHLC candlestick
labelCollision
Handling for labels that do not fit the available width.
Related executable examples: OHLC candlestick
color
ANSI color applied to the axis line, ticks, tick labels, and label.
Related executable examples: OHLC candlestick
YAxis
Numeric Y-axis configuration.
type YAxis = {
/** Explicit numeric extent as `[minimum, maximum]`. */
domain?: readonly [number, number];
/** Exact numeric tick values or an exact tick count of at least two. */
ticks?: number | readonly number[];
/** Axis label rendered outside tick labels. */
label?: string;
/** Formatter called for each numeric Y-axis tick. */
formatter?: Formatter;
/** Hides the axis line, ticks, labels, and axis label. */
hidden?: boolean;
/** Hides tick markers and labels while retaining the axis line. */
hideTicks?: boolean;
/** Reserves enough width for complete Y-axis tick labels. */
showTickLabel?: boolean;
/** ANSI color applied to the axis line, ticks, tick labels, and label. */
color?: Color;
};domain
Explicit numeric extent as [minimum, maximum].
Related executable examples: OHLC candlestick
ticks
Exact numeric tick values or an exact tick count of at least two.
Related executable examples: OHLC candlestick
label
Axis label rendered outside tick labels.
Related executable examples: OHLC candlestick
formatter
Formatter called for each numeric Y-axis tick.
Related executable examples: OHLC candlestick
hidden
Hides the axis line, ticks, labels, and axis label.
Related executable examples: OHLC candlestick
hideTicks
Hides tick markers and labels while retaining the axis line.
Related executable examples: OHLC candlestick
showTickLabel
Reserves enough width for complete Y-axis tick labels.
Related executable examples: OHLC candlestick
color
ANSI color applied to the axis line, ticks, tick labels, and label.
Related executable examples: OHLC candlestick