heatmap(spec: HeatmapSpec): stringheatmap — 6.0.0
Signature
Executable examples
Categorical heatmap
heatmap({
columns: ['Linux', 'macOS', 'Windows'],
rows: ["Node 22","Node 24"],
data: [['pass', 'pass', 'fail'], ['pass', 'pending', 'pass']],
levels: [
{ value: 'pass', symbol: '●', color: 'ansiGreen', label: 'Passed' },
{ value: 'pending', symbol: '○', color: 'ansiYellow', label: 'Pending' },
{ value: 'fail', symbol: '×', color: 'ansiRed', label: 'Failed' },
],
legend: true,
}); Linux macOS Windows
Node 22 ● ● ×
Node 24 ● ○ ●
● Passed ○ Pending × FailedThreshold heatmap
heatmap({
data: [[42, 68, 83], [35, 79, null]],
threshold: {
value: 80,
belowColor: 'ansiCyan',
aboveColor: 'ansiBrightRed',
belowSymbol: '·',
aboveSymbol: '!',
},
});· · !
· ·HeatmapSpec
Complete discrete heatmap or status-matrix specification.
type HeatmapSpec = HeatmapBaseSpec & (Readonly<{
/** Matrix of categorical values; `null` reserves an empty cell. */
data: readonly (readonly HeatmapValue[])[];
/** Exact visual mapping for categorical or already-binned values. */
levels: readonly HeatmapLevel[];
threshold?: never;
}> | Readonly<{
/** Matrix of finite numeric values; `null` reserves an empty cell. */
data: readonly (readonly (number | null)[])[];
levels?: never;
/** Binary visual mapping for raw numeric values. */
threshold: HeatmapThreshold;
}>);rows
Optional row labels; length must match the data row count.
Related executable examples: Categorical heatmap
columns
Optional column labels; length must match the widest data row.
Related executable examples: Categorical heatmap
legend
Renders a level or threshold legend below the matrix.
Related executable examples: Categorical heatmap
symbols
Per-call glyph overrides.
Related executable examples: Categorical heatmap
data
Matrix of categorical values; null reserves an empty cell.
Related executable examples: Categorical heatmap, Threshold heatmap
levels
Exact visual mapping for categorical or already-binned values.
Related executable examples: Categorical heatmap
threshold
Binary visual mapping for raw numeric values.
Related executable examples: Threshold heatmap
HeatmapLevel
Visual mapping for one non-null heatmap value.
type HeatmapLevel = Readonly<{
/** Exact non-null cell value matched by this level. */
value: Exclude<HeatmapValue, null>;
/** One-column glyph. Defaults to the heatmap cell symbol. */
symbol?: string;
/** ANSI color applied to matching cells and their legend marker. */
color?: Color;
/** Legend text. Defaults to the string form of `value`. */
label?: string;
}>;value
Exact non-null cell value matched by this level.
Related executable examples: Categorical heatmap
symbol
One-column glyph. Defaults to the heatmap cell symbol.
Related executable examples: Categorical heatmap
color
ANSI color applied to matching cells and their legend marker.
Related executable examples: Categorical heatmap
label
Legend text. Defaults to the string form of value.
Related executable examples: Categorical heatmap
HeatmapThreshold
Binary visual mapping selected by comparing numeric cells with one threshold.
type HeatmapThreshold = Readonly<{
/** Finite comparison value. */
value: number;
/** ANSI color used for cells below the threshold. */
belowColor: Color;
/** Color used when a cell value equals or exceeds the threshold. */
aboveColor: Color;
/** One-column glyph used below the threshold. */
belowSymbol?: string;
/** One-column glyph used at or above the threshold. */
aboveSymbol?: string;
/** Legend text for values below the threshold. */
belowLabel?: string;
/** Legend text for values at or above the threshold. */
aboveLabel?: string;
}>;belowColor
ANSI color used for cells below the threshold.
Related executable examples: Threshold heatmap
aboveColor
Color used when a cell value equals or exceeds the threshold.
Related executable examples: Threshold heatmap
belowSymbol
One-column glyph used below the threshold.
Related executable examples: Threshold heatmap
aboveSymbol
One-column glyph used at or above the threshold.
Related executable examples: Threshold heatmap
belowLabel
Legend text for values below the threshold.
Related executable examples: Threshold heatmap
aboveLabel
Legend text for values at or above the threshold.
Related executable examples: Threshold heatmap
HeatmapSymbols
Per-call heatmap glyph overrides.
type HeatmapSymbols = Readonly<{
/** Default one-column categorical cell glyph. */
cell?: string;
/** Default one-column glyph for values below a threshold. */
belowThreshold?: string;
/** Default one-column glyph for values at or above a threshold. */
aboveThreshold?: string;
/** One-column glyph used for `null`. */
empty?: string;
/** Display-safe text inserted between cells. */
gap?: string;
}>;cell
Default one-column categorical cell glyph.
Related executable examples: Categorical heatmap
belowThreshold
Default one-column glyph for values below a threshold.
Related executable examples: Threshold heatmap
aboveThreshold
Default one-column glyph for values at or above a threshold.
Related executable examples: Threshold heatmap
gap
Display-safe text inserted between cells.
Related executable examples: Categorical heatmap