UNPKG

@teaui/core

Version:

A high-level terminal UI library for Node

28 lines (27 loc) 1.06 kB
import type { Viewport } from '../../Viewport.js'; import type { Props as ViewProps } from '../../View.js'; import { Style } from '../../Style.js'; import { Chart, type ChartRange, type ChartLayout } from './Chart.js'; export interface BarChartProps<T> extends ViewProps { /** Extract the y-value from each data row */ extract: (row: T) => number; /** Generate x-axis label for a data row */ xLabels?: (row: T, index: number) => string; /** Generate y-axis label from a numeric value */ yLabels?: (value: number) => string; /** Terminal columns per bar (default 1) */ barWidth?: number; /** Gap between bars in terminal columns (default 0) */ gap?: number; /** Style for the bars */ style?: Style; } export declare class BarChart<T> extends Chart<T> { #private; constructor(data: T[], props: BarChartProps<T>); getXRange(): ChartRange; getYRange(): ChartRange; getXLabels(): string[]; getYLabels(count: number): string[]; renderChart(viewport: Viewport, layout: ChartLayout): void; }