plot(coordinates: Coordinates, settings?: Settings): stringplot — 5.4.0
Render numeric line, point, vertical-bar, and horizontal-bar charts with a compact settings object.
Signature
Signature
Executable examples
Source
plot([[0, 2], [1, 5], [2, 3], [3, 8]], {
width: 30,
height: 10,
title: 'Requests',
color: 'ansiCyan',
xLabel: 'minute',
yLabel: 'requests',
});Terminal output
Requests
▲
8┤ ┏━
│ ┃
r │ ┃
e │ ┃
q5┤ ┏━━━━━━━━┓ ┃
u │ ┃ ┃ ┃
e │ ┃ ┃ ┃
s3┤ ┃ ┗━━━━━━━━━┛
t │ ┃
s2┤━━━━━━━━━┛
└┬─────────┬────────┬─────────┬▶
0 1 2 3
minute
Settings
Configuration accepted by plot in version 5.4.0.
type Settings = {
/** Static or callback-based series colors. */
color?: Colors;
/** Plot width in terminal columns. */
width?: number;
/** Plot height in terminal rows. */
height?: number;
/** Explicit Y-axis range as `[minimum, maximum]`. */
yRange?: [number, number];
/** Reserves enough space for complete Y-axis tick labels. */
showTickLabel?: boolean;
/** Hides the X-axis line. */
hideXAxis?: boolean;
/** Hides X-axis tick markers and labels. */
hideXAxisTicks?: boolean;
/** Hides the Y-axis line. */
hideYAxis?: boolean;
/** Hides Y-axis tick markers and labels. */
hideYAxisTicks?: boolean;
/** Explicit numeric X-axis tick values. */
customXAxisTicks?: number[];
/** Explicit numeric Y-axis tick values. */
customYAxisTicks?: number[];
/** Chart title rendered above the plot. */
title?: string;
/** X-axis label. */
xLabel?: string;
/** Y-axis label. */
yLabel?: string;
/** Numeric reference lines. */
thresholds?: Threshold[];
/** Point overlays. */
points?: GraphPoint[];
/** Fills the area between line series and the X-axis baseline. */
fillArea?: boolean;
/** Legend placement and labels. */
legend?: Legend;
/** Explicit X-axis and Y-axis intersection. */
axisCenter?: MaybePoint;
/** Shared numeric axis-label formatter. */
formatter?: Formatter;
/** Custom renderer function for occupied series cells. */
lineFormatter?: (args: LineFormatterArgs) => CustomSymbol | CustomSymbol[];
/** Per-call symbol overrides. */
symbols?: Symbols;
/** Graph primitive. Defaults to `line`. */
mode?: GraphMode;
/** Logs out-of-bounds drawing attempts. */
debugMode?: boolean;
};Legend
Legend configuration.
type Legend = {
/** Legend position. */
position?: "left" | "right" | "top" | "bottom";
/** Series label or labels. */
series?: string | string[];
/** Point label or labels. */
points?: string | string[];
/** Threshold label or labels. */
thresholds?: string | string[];
};Threshold
Numeric X-axis or Y-axis threshold.
type Threshold = {
/** X coordinate for a vertical threshold. */
x?: number;
/** Y coordinate for a horizontal threshold. */
y?: number;
/** ANSI threshold color. */
color?: Color;
};GraphPoint
Numeric point overlay.
type GraphPoint = {
/** X coordinate. */
x: number;
/** Y coordinate. */
y: number;
/** ANSI point color. */
color?: Color;
};