plot(data: PlotCoordinates, settings?: Settings): stringplot — 6.0.0
Signature
Executable examples
Numeric plot
plot([[0, 2], [1, 5], [2, 3], [3, 8]], {
width: 30,
height: 10,
title: 'Requests',
color: 'ansiCyan',
interpolation: 'linear',
xAxis: { ticks: 4, label: 'minute' },
yAxis: { domain: [0, 10], label: 'requests' },
});
Requests
▲
│
│
r8┤ ┏━━
e │ ┏━┛
q5┤ ┏┓ ┏━┛
u │ ┏━━┛┗━━━━┓ ┏━┛
e3┤ ┏━━━┛ ┗━━━━━┛
s2┤━━┛
t │
s │
└┬─────────┬────────┬─────────┬▶
0 1 2 3
minute
Settings
Complete configuration for numeric plot rendering.
type Settings = {
/** Static series color configuration. */
color?: Colors;
/** Fixed plot width or `auto` for active terminal columns. Defaults to an input-derived width. */
width?: ChartWidth;
/** Plot height in terminal rows. Defaults to an input-derived height unless `aspectRatio` applies. */
height?: number;
/** Desired physical width-to-height ratio used when height is derived. */
aspectRatio?: number;
/** Explicit numeric Y extent as `[minimum, maximum]`. */
yRange?: [number, number];
/** Line behavior outside explicit domains. Defaults to `discard`. */
overflow?: Overflow;
/** Plot-cell backend. Defaults to `ascii`. */
renderer?: Renderer;
/** Reserves enough width for complete Y-axis tick labels. */
showTickLabel?: boolean;
/** Hides the X-axis line, ticks, labels, and axis label. */
hideXAxis?: boolean;
/** Hides X-axis tick markers and labels while retaining the axis line. */
hideXAxisTicks?: boolean;
/** Hides the Y-axis line, ticks, labels, and axis label. */
hideYAxis?: boolean;
/** Hides Y-axis tick markers and labels while retaining the axis line. */
hideYAxisTicks?: boolean;
/** Explicit finite X-axis tick values. */
customXAxisTicks?: number[];
/** Explicit finite Y-axis tick values. */
customYAxisTicks?: number[];
/** Title rendered above the chart. */
title?: string;
/** ANSI color applied to the title. */
titleColor?: Color;
/** X-axis label. */
xLabel?: string;
/** Y-axis label. */
yLabel?: string;
/** Numeric horizontal and/or vertical reference lines. */
thresholds?: Threshold[];
/** Point overlays rendered in data coordinates. */
points?: GraphPoint[];
/** Fills the region between line series and the X-axis baseline. */
fillArea?: boolean;
/** Legend placement, labels, and ANSI color. */
legend?: Legend;
/** Explicit X/Y axis intersection; `undefined` preserves an inferred coordinate. */
axisCenter?: MaybePoint;
/** Shared numeric axis-label formatter. Structured axis formatters take precedence. */
formatter?: Formatter;
/** Custom glyph callback for occupied series cells. */
lineFormatter?: (args: LineFormatterArgs) => CustomSymbol | CustomSymbol[];
/** Per-call glyph overrides. */
symbols?: Symbols;
/** ANSI color applied to the configured border glyph. */
borderColor?: Color;
/** ANSI color applied to background glyphs. */
backgroundColor?: Color;
/** Graph primitive. Defaults to `line`. */
mode?: GraphMode;
/** Line-segment interpolation. Defaults to `step`. */
interpolation?: Interpolation;
/** Shared or per-series dynamic color strategy. */
coloring?: Coloring | readonly (Coloring | undefined)[];
/** Multi-series bar arrangement. Defaults to `overlap`. */
barLayout?: BarLayout;
/** Enables bar endpoint labels or configures their text and color. */
valueLabels?: ChartValueLabels;
/** Logs out-of-bounds drawing attempts for diagnostics. */
debugMode?: boolean;
/** Structured X-axis fields; each supplied field overrides its flat alias. */
xAxis?: XAxis;
/** Structured Y-axis fields; each supplied field overrides its flat alias. */
yAxis?: YAxis;
};width
Fixed plot width or auto for active terminal columns. Defaults to an input-derived width.
Related executable examples: Numeric plot
height
Plot height in terminal rows. Defaults to an input-derived height unless aspectRatio applies.
Related executable examples: Numeric plot
aspectRatio
Desired physical width-to-height ratio used when height is derived.
Related executable examples: Numeric plot
yRange
Explicit numeric Y extent as [minimum, maximum].
Related executable examples: Numeric plot
overflow
Line behavior outside explicit domains. Defaults to discard.
Related executable examples: Numeric plot
renderer
Plot-cell backend. Defaults to ascii.
Related executable examples: Numeric plot
showTickLabel
Reserves enough width for complete Y-axis tick labels.
Related executable examples: Numeric plot
hideXAxis
Hides the X-axis line, ticks, labels, and axis label.
Related executable examples: Numeric plot
hideXAxisTicks
Hides X-axis tick markers and labels while retaining the axis line.
Related executable examples: Numeric plot
hideYAxis
Hides the Y-axis line, ticks, labels, and axis label.
Related executable examples: Numeric plot
hideYAxisTicks
Hides Y-axis tick markers and labels while retaining the axis line.
Related executable examples: Numeric plot
customXAxisTicks
Explicit finite X-axis tick values.
Related executable examples: Numeric plot
customYAxisTicks
Explicit finite Y-axis tick values.
Related executable examples: Numeric plot
thresholds
Numeric horizontal and/or vertical reference lines.
Related executable examples: Numeric plot
points
Point overlays rendered in data coordinates.
Related executable examples: Numeric plot
fillArea
Fills the region between line series and the X-axis baseline.
Related executable examples: Numeric plot
legend
Legend placement, labels, and ANSI color.
Related executable examples: Numeric plot
axisCenter
Explicit X/Y axis intersection; undefined preserves an inferred coordinate.
Related executable examples: Numeric plot
formatter
Shared numeric axis-label formatter. Structured axis formatters take precedence.
Related executable examples: Numeric plot
lineFormatter
Custom glyph callback for occupied series cells.
Related executable examples: Numeric plot
borderColor
ANSI color applied to the configured border glyph.
Related executable examples: Numeric plot
backgroundColor
ANSI color applied to background glyphs.
Related executable examples: Numeric plot
interpolation
Line-segment interpolation. Defaults to step.
Related executable examples: Numeric plot
coloring
Shared or per-series dynamic color strategy.
Related executable examples: Numeric plot
barLayout
Multi-series bar arrangement. Defaults to overlap.
Related executable examples: Numeric plot
valueLabels
Enables bar endpoint labels or configures their text and color.
Related executable examples: Numeric plot
debugMode
Logs out-of-bounds drawing attempts for diagnostics.
Related executable examples: Numeric plot
xAxis
Structured X-axis fields; each supplied field overrides its flat alias.
Related executable examples: Numeric plot
yAxis
Structured Y-axis fields; each supplied field overrides its flat alias.
Related executable examples: Numeric plot
Legend
Legend placement, labels, and color for plot.
type Legend = {
/** Placement relative to the plot. Defaults to `bottom`. */
position?: LegendPosition;
/** One series label or labels indexed by source series. */
series?: string | string[];
/** One point label or labels indexed by overlay point. */
points?: string | string[];
/** One threshold label or labels indexed by threshold. */
thresholds?: string | string[];
/** ANSI color applied to legend labels. */
color?: Color;
};position
Placement relative to the plot. Defaults to bottom.
Related executable examples: Numeric plot
series
One series label or labels indexed by source series.
Related executable examples: Numeric plot
points
One point label or labels indexed by overlay point.
Related executable examples: Numeric plot
thresholds
One threshold label or labels indexed by threshold.
Related executable examples: Numeric plot
Threshold
Numeric vertical and/or horizontal reference line.
type Threshold = {
/** X coordinate for a vertical reference line. */
x?: number;
/** Y coordinate for a horizontal reference line. */
y?: number;
/** ANSI color applied to the reference line. */
color?: Color;
};y
Y coordinate for a horizontal reference line.
Related executable examples: Numeric plot
color
ANSI color applied to the reference line.
Related executable examples: Numeric plot
GraphPoint
Point overlay positioned in numeric data coordinates.
type GraphPoint = {
/** Numeric X coordinate. */
x: number;
/** Numeric Y coordinate. */
y: number;
/** ANSI color applied to the point glyph. */
color?: Color;
};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: Numeric plot
domain
Explicit category order or continuous scale extent.
Related executable examples: Numeric plot
ticks
Exact native tick values or an exact tick count of at least two.
Related executable examples: Numeric plot
label
Axis label rendered outside tick labels.
Related executable examples: Numeric plot
formatter
Formatter called with native X values.
Related executable examples: Numeric plot
hidden
Hides the axis line, ticks, labels, and axis label.
Related executable examples: Numeric plot
hideTicks
Hides tick markers and labels while retaining the axis line.
Related executable examples: Numeric plot
labelCollision
Handling for labels that do not fit the available width.
Related executable examples: Numeric plot
color
ANSI color applied to the axis line, ticks, tick labels, and label.
Related executable examples: Numeric plot
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: Numeric plot
ticks
Exact numeric tick values or an exact tick count of at least two.
Related executable examples: Numeric plot
label
Axis label rendered outside tick labels.
Related executable examples: Numeric plot
formatter
Formatter called for each numeric Y-axis tick.
Related executable examples: Numeric plot
hidden
Hides the axis line, ticks, labels, and axis label.
Related executable examples: Numeric plot
hideTicks
Hides tick markers and labels while retaining the axis line.
Related executable examples: Numeric plot
showTickLabel
Reserves enough width for complete Y-axis tick labels.
Related executable examples: Numeric plot
color
ANSI color applied to the axis line, ticks, tick labels, and label.
Related executable examples: Numeric plot
Coloring
Dynamic per-cell series-color strategy.
type Coloring = {
/** Selects callback-based colors. */
type: 'conditional';
/** Returns a color or `undefined` to use the static series fallback. */
getColor: (context: ColorContext) => Color | undefined;
} | {
/** Selects equal-band palette coloring. */
type: 'gradient';
/** Data-space axis used to select a palette band. */
by: 'x' | 'y';
/** Nonempty ordered ANSI color palette. */
colors: readonly Color[];
/** Optional finite palette extent. Defaults to the resolved chart domain. */
domain?: readonly [number, number];
};type
Selects callback-based colors.
Related executable examples: Numeric plot
getColor
Returns a color or undefined to use the static series fallback.
Related executable examples: Numeric plot
by
Data-space axis used to select a palette band.
Related executable examples: Numeric plot
colors
Nonempty ordered ANSI color palette.
Related executable examples: Numeric plot
domain
Optional finite palette extent. Defaults to the resolved chart domain.
Related executable examples: Numeric plot
ChartValueLabels
Enables bar endpoint labels or configures their text and ANSI color.
type ChartValueLabels = boolean | {
/** Formats the rendered value; normalized layouts receive a percentage. */
formatter?: ValueLabelFormatter<X>;
/** ANSI color applied to every value label. */
color?: Color;
};formatter
Formats the rendered value; normalized layouts receive a percentage.
Related executable examples: Numeric plot