-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchartscii.ts
29 lines (23 loc) · 1012 Bytes
/
chartscii.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import HorizontalChartFormatter from './formatters/horizontal';
import ChartProcessor from './processor/processor';
import Options from './options/options';
import { InputData, ChartOptions, ChartData, CustomizationOptions } from './types/types';
import VerticalChartFormatter from './formatters/vertical';
class Chartscii {
private chart: ChartData;
private asciiChart: string;
constructor(data: InputData[], options?: CustomizationOptions) {
const config = new Options(options) as ChartOptions;
const processor = new ChartProcessor(config);
const [chart, processedOptions] = processor.process(data);
this.chart = chart;
const chartFormatter = config.orientation === 'vertical'
? new VerticalChartFormatter(chart, processedOptions)
: new HorizontalChartFormatter(processedOptions);
this.asciiChart = chartFormatter.format(this.chart);
}
create() {
return this.asciiChart;
}
}
export default Chartscii;