simple-ascii-chart
Version:
Simple ascii chart generator
147 lines (146 loc) • 6.25 kB
TypeScript
import { Colors, Formatter, Graph, Legend, MultiLine, Symbols, Threshold, FormatterHelpers } from '../types';
/**
* Adds a title to the graph at the top.
* @param {object} options - Object containing title options.
* @param {string} options.title - The title text.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.backgroundSymbol - Background symbol for the graph.
* @param {number} options.plotWidth - Width of the plot.
* @param {number} options.yShift - Vertical shift for positioning.
*/
export declare const setTitle: ({ title, graph, backgroundSymbol, plotWidth, yShift, debugMode, }: {
title: string;
graph: Graph;
backgroundSymbol: string;
plotWidth: number;
yShift: number;
debugMode?: boolean;
}) => void;
/**
* Adds an x-axis label centered at the bottom of the graph.
* @param {object} options - Object containing x-label options.
* @param {string} options.xLabel - The x-axis label text.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.backgroundSymbol - Background symbol for the graph.
* @param {number} options.plotWidth - Width of the plot.
* @param {number} options.yShift - Vertical shift for positioning.
*/
export declare const addXLable: ({ graph, plotWidth, yShift, backgroundSymbol, xLabel, debugMode, }: {
xLabel: string;
graph: Graph;
backgroundSymbol: string;
plotWidth: number;
yShift: number;
debugMode?: boolean;
}) => void;
/**
* Adds a y-axis label centered on the left side of the graph.
* @param {object} options - Object containing y-label options.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.backgroundSymbol - Background symbol for the graph.
* @param {string} options.yLabel - The y-axis label text.
*/
export declare const addYLabel: ({ graph, backgroundSymbol, yLabel, debugMode, }: {
graph: Graph;
backgroundSymbol: string;
yLabel: string;
debugMode?: boolean;
}) => void;
/**
* Adds a legend to the specified position on the graph (top, bottom, left, or right).
* @param {object} options - Object containing legend options.
* @param {Graph} options.graph - The graph array to modify.
* @param {Legend} options.legend - Configuration for the legend's position and series.
* @param {string} options.backgroundSymbol - Background symbol for the graph.
* @param {MultiLine} options.input - Input data series for the chart.
* @param {Colors} [options.color] - Color(s) for each series.
* @param {Symbols} [options.symbols] - Custom symbols for the chart.
* @param {boolean} [options.fillArea] - Whether to fill the area below the lines.
*/
export declare const addLegend: ({ graph, legend, backgroundSymbol, color, symbols, fillArea, input, debugMode, }: {
graph: Graph;
legend: Legend;
backgroundSymbol: string;
input: MultiLine;
color?: Colors;
symbols?: Symbols;
fillArea?: boolean;
debugMode?: boolean;
}) => void;
/**
* Adds a border around the graph.
* @param {object} options - Object containing border options.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.borderSymbol - The symbol to use for the border.
*/
export declare const addBorder: ({ graph, borderSymbol }: {
graph: Graph;
borderSymbol: string;
}) => void;
/**
* Fills the background of empty cells in the graph with a specified symbol.
* @param {object} options - Object containing background fill options.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.backgroundSymbol - Symbol to fill empty cells with.
* @param {string} options.emptySymbol - Symbol representing empty cells.
*/
export declare const addBackgroundSymbol: ({ graph, backgroundSymbol, emptySymbol, debugMode, }: {
graph: Graph;
backgroundSymbol: string;
emptySymbol: string;
debugMode?: boolean;
}) => void;
/**
* Adds threshold lines to the graph based on specified x or y values.
* @param {object} options - Object containing threshold options.
* @param {Graph} options.graph - The graph array to modify.
* @param {Threshold[]} options.thresholds - Array of threshold objects with x, y, and color.
* @param {object} options.axis - The axis configuration.
* @param {number} options.plotWidth - Width of the plot.
* @param {number} options.plotHeight - Height of the plot.
* @param {number[]} options.expansionX - x-axis range for scaling.
* @param {number[]} options.expansionY - y-axis range for scaling.
*/
export declare const addThresholds: ({ graph, thresholds, axis, plotWidth, plotHeight, expansionX, expansionY, debugMode, }: {
graph: Graph;
thresholds: Threshold[];
axis: {
x: number;
y: number;
};
plotWidth: number;
plotHeight: number;
expansionX: number[];
expansionY: number[];
debugMode?: boolean;
}) => void;
/**
* Fills the area below chart symbols with the specified area symbol.
* @param {object} options - Object containing fill options.
* @param {Graph} options.graph - The graph array to modify.
* @param {Symbols['chart']} options.chartSymbols - Chart symbols to use for filling.
*/
export declare const setFillArea: ({ graph, chartSymbols, debugMode, }: {
graph: Graph;
chartSymbols: Symbols["chart"];
debugMode?: boolean;
}) => void;
/**
* Removes any completely empty lines from the graph.
* @param {object} options - Object containing empty line removal options.
* @param {Graph} options.graph - The graph array to modify.
* @param {string} options.backgroundSymbol - Background symbol for identifying empty lines.
*/
export declare const removeEmptyLines: ({ graph, backgroundSymbol, }: {
graph: Graph;
backgroundSymbol: string;
}) => void;
/**
* Returns a label transformation function using the specified formatter.
* @param {object} options - Object containing formatter options.
* @param {Formatter} [options.formatter] - Formatter function to apply to labels.
* @returns {Formatter} - A formatter function for transforming labels.
*/
export declare const getTransformLabel: ({ formatter }: {
formatter?: Formatter;
}) => (value: number, helpers: FormatterHelpers) => string | number;