sparkline(values, options?: SparklineOptions): stringsparkline — 6.0.0
Signature
Executable examples
Sparkline options
sparkline([1, 3, null, 2], {
threshold: { value: 3, belowColor: 'ansiBlue', aboveColor: 'ansiRed' },
symbols: { empty: '_' },
});▁█_▅SparklineOptions
Visual options for compact sparkline output.
type SparklineOptions = Readonly<{
/** Per-call level and empty-cell glyph overrides. */
symbols?: SparklineSymbols;
}> & ({
/** ANSI color applied globally or mapped one-to-one with input values. */
color?: SparklineColor;
threshold?: never;
} | {
color?: never;
/** ANSI colors selected from each finite value's threshold relation. */
threshold: SparklineThreshold;
});symbols
Per-call level and empty-cell glyph overrides.
Related executable examples: Sparkline options
color
ANSI color applied globally or mapped one-to-one with input values.
Related executable examples: Sparkline options
threshold
ANSI colors selected from each finite value's threshold relation.
Related executable examples: Sparkline options
SparklineThreshold
Colors selected by comparing each finite value with one numeric threshold.
type SparklineThreshold = Readonly<{
/** Finite comparison value. */
value: number;
/** ANSI color used for values below the threshold. */
belowColor: Color;
/** Color used when a value equals or exceeds the threshold. */
aboveColor: Color;
}>;belowColor
ANSI color used for values below the threshold.
Related executable examples: Sparkline options
aboveColor
Color used when a value equals or exceeds the threshold.
Related executable examples: Sparkline options
SparklineSymbols
Per-call sparkline glyph overrides.
type SparklineSymbols = Readonly<{
/** Exactly eight one-column glyphs ordered from lowest to highest. */
levels?: readonly [string, string, string, string, string, string, string, string];
/** One-column glyph used for `null`. */
empty?: string;
}>;levels
Exactly eight one-column glyphs ordered from lowest to highest.
Related executable examples: Sparkline options