import plot, * as asciiChart from 'simple-ascii-chart'Shared API reference — 5.4.0
Inspect the constants, symbols, formatter contexts, and public types exported by version 5.4.0.
Signature
Signature
Executable examples
Source
console.log(Object.keys(AXIS));
console.log(Object.keys(CHART));
console.log(LAYOUT);Terminal output
n, ns, y, nse, x, we, e, intersectionXY, intersectionX, intersectionY
we, wns, ns, nse, wsn, sne, area
{"MIN_PLOT_HEIGHT":3,"DEFAULT_DECIMAL_PLACES":3,"K_FORMAT_THRESHOLD":1000,"DEFAULT_PADDING":2,"DEFAULT_Y_SHIFT_OFFSET":1}Public exports
AXIS
Symbols used to draw chart axes.
AXIS: {
n: string;
ns: string;
y: string;
nse: string;
x: string;
we: string;
e: string;
intersectionXY: string;
intersectionX: string;
intersectionY: string;
}CHART
Symbols used to draw line and area charts.
CHART: {
we: string;
wns: string;
ns: string;
nse: string;
wsn: string;
sne: string;
area: string;
}EMPTY
Symbol used for an empty graph cell.
EMPTY: " "THRESHOLDS
Symbols used to draw X-axis and Y-axis thresholds.
THRESHOLDS: { x: string; y: string }POINT
Symbol used for point overlays.
POINT: "●"LAYOUT
Layout and formatting constants used by version 5.4.0.
LAYOUT: {
readonly MIN_PLOT_HEIGHT: 3;
readonly DEFAULT_DECIMAL_PLACES: 3;
readonly K_FORMAT_THRESHOLD: 1000;
readonly DEFAULT_PADDING: 2;
readonly DEFAULT_Y_SHIFT_OFFSET: 1;
}Public types and closed variants
GraphMode
Plot modes supported by version 5.4.0.
type GraphMode = "line" | "point" | "bar" | "horizontalBar";Color
ANSI color names supported by version 5.4.0.
type Color = `ansi${
| "Red"
| "Green"
| "Black"
| "Yellow"
| "Blue"
| "Magenta"
| "Cyan"
| "White"}`;Coordinates
Input accepted by plot.
type Coordinates = SingleLine | MultiLine;Point
Numeric X and Y coordinates.
type Point = [x: number, y: number];MaybePoint
Optional or partially defined axis-center coordinates.
type MaybePoint = Point | undefined | [number | undefined, number | undefined];Colors
Static or callback-based series colors.
type Colors = Color | Color[] | ColorGetter;Symbols
Per-call symbol overrides.
type Symbols = {
/** Axis-symbol overrides. */
axis?: Partial<typeof AXIS>;
/** Line and area-symbol overrides. */
chart?: Partial<typeof CHART>;
/** Empty-cell symbol. */
empty?: string;
/** Background-cell symbol. */
background?: string;
/** Border symbol. */
border?: string;
/** Threshold-symbol overrides. */
thresholds?: Partial<typeof THRESHOLDS>;
/** Point-overlay symbol. */
point?: string;
};FormatterHelpers
Context received by the axis formatter.
type FormatterHelpers = {
/** Axis currently being formatted. */
axis: "x" | "y";
/** Resolved numeric X range. */
xRange: number[];
/** Resolved numeric Y range. */
yRange: number[];
};LineFormatterArgs
Context received by the custom line renderer.
type LineFormatterArgs = {
/** Original X coordinate. */
x: number;
/** Original Y coordinate. */
y: number;
/** Resolved plot-column coordinate. */
plotX: number;
/** Resolved plot-row coordinate. */
plotY: number;
/** Source data series. */
input: SingleLine;
/** Source datum index. */
index: number;
/** Minimum resolved Y value. */
minY: number;
/** Minimum resolved X value. */
minX: number;
/** Resolved X expansion table. */
expansionX: number[];
/** Resolved Y expansion table. */
expansionY: number[];
/** Converts data coordinates to plot coordinates. */
toPlotCoordinates: (x: number, y: number) => Point;
};