simple-ascii-chart
Version:
Simple ascii chart generator
75 lines (74 loc) • 2.87 kB
TypeScript
import { Symbols, MultiLine, Formatter, Coordinates } from '../types';
/**
* Merges custom symbols with default axis symbols and defines plot symbols.
* @param {object} options - An object containing optional custom symbols.
* @param {Symbols} options.symbols - Custom symbols for the plot.
* @returns {object} - Object containing the merged axis symbols, and defined symbols for empty, background, and border.
*/
export declare const getSymbols: ({ symbols }: {
symbols?: Symbols;
}) => {
axisSymbols: {
n: string;
ns: string;
y: string;
nse: string;
x: string;
we: string;
e: string;
};
emptySymbol: string;
backgroundSymbol: string;
borderSymbol: string | undefined;
};
/**
* Determines plot size and range based on provided data and dimensions.
* @param {object} options - An object containing input data and optional dimensions.
* @param {MultiLine} options.input - The multiline array of points.
* @param {number} [options.width] - Optional width of the plot.
* @param {number} [options.height] - Optional height of the plot.
* @param {[number, number]} [options.yRange] - Optional range for the y-axis.
* @returns {object} - Object containing min x value, plot width, plot height, and x and y expansions.
*/
export declare const getChartSize: ({ input, width, height, yRange, }: {
input: MultiLine;
width?: number;
height?: number;
yRange?: [number, number];
}) => {
minX: number;
minY: number;
plotWidth: number;
plotHeight: number;
expansionX: number[];
expansionY: [number, number];
};
/**
* Calculates shifts for x and y labels, based on the longest label length.
* @param {object} options - The input data and formatting options.
* @param {MultiLine} options.input - The multiline array of points.
* @param {Formatter} options.transformLabel - A function to transform label values.
* @param {number[]} options.expansionX - The x-axis range.
* @param {number[]} options.expansionY - The y-axis range.
* @param {number} options.minX - The minimum x value for label calculation.
* @returns {object} - Object containing the calculated xShift and yShift.
*/
export declare const getLabelShift: ({ input, transformLabel, expansionX, expansionY, minX, }: {
input: MultiLine;
transformLabel: Formatter;
expansionX: number[];
expansionY: number[];
minX: number;
}) => {
xShift: number;
yShift: number;
};
/**
* Normalizes raw input data into a consistent multi-line format.
* @param {object} options - Contains the raw input data.
* @param {Coordinates} options.rawInput - Input coordinates, either single or multi-line.
* @returns {MultiLine} - The formatted data as a multi-line array of points.
*/
export declare const getInput: ({ rawInput }: {
rawInput: Coordinates;
}) => MultiLine;