UNPKG

thistogram

Version:

A simple text based histogram and chart generator

58 lines 2.7 kB
export interface HistogramDrawOptions { /** * The characters used to draw the box plot. * top-left, top-right, bottom-right, bottom-left, vertical, horizontal, left-T, right-T, bottom-T, top-T, cross */ boxSymbols: string[]; histoChars: string[]; } export interface HistogramOptions { /** The entire table width in characters, including the axis labels, default is 80 */ width?: number; /** The max width of the axis labels on the left, default is 10% of the width */ maxLabelWidth?: number; drawOptions?: Partial<HistogramDrawOptions>; /** The maximum value to show in the graph, defaults to the maximum value in the data. */ max?: number; /** The minimum value to show in the graph, defaults to 0 or the the minimum value whichever is lower */ min?: number; title?: string; /** Show the actual values. */ showValues?: boolean; /** The number of significant digits to show in the values. */ significantDigits?: number; /** * The column headers. * The first column is the label, the second is the value, the third is the min value, and the fourth is the max value. */ headers?: string[]; /** * The chart type to use, defaults to 'bar' */ type?: 'bar' | 'point' | 'point-min-max'; } export type DataLine = readonly [label: string | number, value: number] | readonly [label: string | number, value: number, min: number, max: number]; export type Data = readonly DataLine[]; export declare function histogram(data: Data, options?: HistogramOptions): string; /** * Generate a point line for a value * @param value - between 0 and 1 inclusive. * @param width - the width of the graph in characters * @param padding - optional padding character, defaults to space. * @param pointChar - optional point character, defaults to `●` * @returns a string of the point */ export declare function point(value: number, width: number, padding?: string, pointChar?: string): string; export declare const valueMinMaxSymbols: readonly string[]; /** * * @param value - between 0 and 1 inclusive. * @param minVal - the minimum value, defaults to the value * @param maxVal - the maximum value, defaults to the value * @param width - the width of the graph in characters * @param padding - optional padding character, defaults to space. * @param symbols - the symbols to use for the min, max, and value, defaults to `['●', '┣', '━', '┫']` * @returns */ export declare function pointMinMax(value: number, minVal: number | undefined, maxVal: number | undefined, width: number, padding?: string, symbols?: readonly string[]): string; //# sourceMappingURL=histogram.d.ts.map