Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prototeam/tcharts.js
:chart_with_downwards_trend: Lightweight and fast terminal ASCII charts for nodejs and browser.
https://github.com/prototeam/tcharts.js
ascii ascii-charts chart console console-charts tcharts terminal terminal-charts
Last synced: about 2 months ago
JSON representation
:chart_with_downwards_trend: Lightweight and fast terminal ASCII charts for nodejs and browser.
- Host: GitHub
- URL: https://github.com/prototeam/tcharts.js
- Owner: ProtoTeam
- Created: 2017-06-21T01:45:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-17T02:38:39.000Z (about 7 years ago)
- Last Synced: 2024-10-16T09:14:40.551Z (3 months ago)
- Topics: ascii, ascii-charts, chart, console, console-charts, tcharts, terminal, terminal-charts
- Language: JavaScript
- Homepage:
- Size: 69.3 KB
- Stars: 174
- Watchers: 6
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tcharts.js
> [TCharts.js](http://tcharts.org) is a Lightweight and fast terminal ASCII charts for nodejs and browser.
[![Ver](https://img.shields.io/npm/v/tcharts.js.svg)](https://www.npmjs.com/package/tcharts.js) [![Build Status](https://travis-ci.org/ProtoTeam/tcharts.js.svg?branch=master)](https://travis-ci.org/ProtoTeam/tcharts.js) [![Coverage Status](https://coveralls.io/repos/github/ProtoTeam/tcharts.js/badge.svg?branch=master)](https://coveralls.io/github/ProtoTeam/tcharts.js)
```
+--------------+----------------------+---------------------+
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | C:25% | Hello:25% |
| | | |
| | | |
| A:25% | | |
| | | |
| | | |
| +----------------------+---------------------+
| | |
| | |
| | |
| | B:25% |
| | |
| | |
+--------------+--------------------------------------------+```
## 1. Install & Usage
> npm i -S tcharts.js
### Table
```js
const TCharts = require('tcharts.js');
const { Table } = TCharts;const table = new Table(0.2); // set gap rate = 0.2
table.setData([
['標識符', '名字', '生日'],
['#1', '圖靈', 24],
['#2', '潘金蓮', false],
['#3', '西門慶', null],
['#4', '明日花绮罗'],
]);
console.log(table.string());
```### Bar
```js
const TCharts = require('tcharts.js');
const { Bar } = TCharts;const bar = new Bar();
bar.setData([
{value:100, name:'A'},
{value:45, name:'B'},
{value:70, name:'C'},
{value:30, name:'D'},
]);
console.log(bar.string());
```### HBar
```js
const TCharts = require('tcharts.js');
const { HBar } = TCharts;const hbar = new HBar();
hbar.setData([
{value: 100, name: 'A'},
{value: 45, name: 'B'},
{value: 70, name: 'C'},
{value: 30, name: 'D'},
]);
console.log(hbar.string());```
### Box
```js
const TCharts = require('tcharts.js');
const { Box } = TCharts;const box = new Box(60, 20); // width, height
box.setData([
{value:100, name:'A'},
{value:100, name:'B'},
{value:100, name:'C'},
{value:100, name:'Hello'},
]);
console.log(box.string());
```## 2. Supported charts
- `Bar`: bar chart, with x, y.
- `HBar`: horizontal bar chart.
- `Box`: box chart showing with a square.
- `Table`: data table in terminal.How to use them, you can see the testcases in `__tests__` folder.
## 3. Build & Test
```
npm inpm run build
npm test
```Then you can see the result of test cases.
## 4. License
ISC@[ProtoTeam](https://github.com/ProtoTeam).