UNPKG

simple-ascii-chart

Version:
191 lines (190 loc) 8.96 kB
import { THRESHOLDS } from '../constants/index.js'; import { Colors, Formatter, Graph, Legend, MultiLine, Symbols, Threshold, FormatterHelpers, GraphPoint } from '../types/index.js'; /** * 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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ 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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ export declare const addXLabel: ({ 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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ 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 {string} options.pointSymbol - Symbol used to draw points. * @param {GraphPoint[]} [options.points] - Points to render, with optional colors. * @param {Threshold[]} [options.thresholds] - Thresholds for the plot. * @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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ export declare const addLegend: ({ graph, legend, backgroundSymbol, color, symbols, fillArea, input, pointSymbol, debugMode, points, thresholds, }: { graph: Graph; legend: Legend; backgroundSymbol: string; input: MultiLine; color?: Colors; pointSymbol: string; symbols?: Symbols; fillArea?: boolean; debugMode?: boolean; points?: GraphPoint[]; thresholds?: Threshold[]; }) => 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.backgroundSymbol - The symbol to use for the background. * @param {string} options.borderSymbol - The symbol to use for the border. */ export declare const addBorder: ({ graph, borderSymbol, backgroundSymbol, }: { graph: Graph; borderSymbol: string; backgroundSymbol: 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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ export declare const addBackgroundSymbol: ({ graph, backgroundSymbol, emptySymbol, debugMode, }: { graph: Graph; backgroundSymbol: string; emptySymbol: string; debugMode?: boolean; }) => void; /** * Adds points to the graph at specified (x, y) coordinates. * * @param {object} options - Configuration options. * @param {Graph} options.graph - The graph array to modify. * @param {GraphPoint[]} options.points - Points to render, with optional colors. * @param {number} options.plotWidth - Width of the plot. * @param {number} options.plotHeight - Height of the plot. * @param {number[]} options.expansionX - Range of x-values for scaling. * @param {number[]} options.expansionY - Range of y-values for scaling. * @param {string} options.pointSymbol - Symbol used to draw the point. * @param {boolean} [options.debugMode] - Enables debug logging. */ export declare const addPoints: ({ graph, points, plotWidth, plotHeight, expansionX, expansionY, pointSymbol, debugMode, }: { graph: Graph; points: GraphPoint[]; plotWidth: number; plotHeight: number; expansionX: number[]; expansionY: number[]; pointSymbol: string; debugMode?: boolean; }) => void; /** * Draws threshold lines on the graph at specified x and/or y coordinates. * * @param {object} options - Configuration object for threshold rendering. * @param {Graph} options.graph - The 2D graph matrix to modify. * @param {Threshold[]} options.thresholds - List of threshold definitions with x, y, and optional color. * @param {object} options.axis - Axis configuration defining origin point. * @param {number} options.axis.x - X-position of the Y-axis on the graph. * @param {number} options.axis.y - Y-position of the X-axis on the graph. * @param {number} options.plotWidth - Width of the plot area in characters. * @param {number} options.plotHeight - Height of the plot area in characters. * @param {number[]} options.expansionX - Original data range for the X-axis, used for scaling. * @param {number[]} options.expansionY - Original data range for the Y-axis, used for scaling. * @param {typeof THRESHOLDS} options.thresholdSymbols - Symbols used to draw horizontal and vertical threshold lines. * @param {boolean} [options.debugMode=false] - Enables debug logging for invalid coordinates or out-of-bounds access. */ export declare const addThresholds: ({ graph, thresholds, axis, plotWidth, plotHeight, expansionX, expansionY, thresholdSymbols, debugMode, }: { graph: Graph; thresholds: Threshold[]; axis: { x: number; y: number; }; plotWidth: number; plotHeight: number; expansionX: number[]; expansionY: number[]; thresholdSymbols: typeof THRESHOLDS; 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. * @param {boolean} [options.debugMode=false] - If true, logs errors for out-of-bounds access. */ 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;