Code Monkey home page Code Monkey logo

tcharts.js's Introduction

tcharts.js

TCharts.js is a Lightweight and fast terminal ASCII charts for nodejs and browser.

Ver Build Status Coverage Status

    +--------------+----------------------+---------------------+
    |              |                      |                     |
    |              |                      |                     |
    |              |                      |                     |
    |              |                      |                     |
    |              |                      |                     |
    |              |                      |                     |
    |              |        C:25%         |      Hello:25%      |
    |              |                      |                     |
    |              |                      |                     |
    |    A:25%     |                      |                     |
    |              |                      |                     |
    |              |                      |                     |
    |              +----------------------+---------------------+
    |              |                                            |
    |              |                                            |
    |              |                                            |
    |              |                   B:25%                    |
    |              |                                            |
    |              |                                            |
    +--------------+--------------------------------------------+

1. Install & Usage

npm i -S tcharts.js

Table

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

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

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

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 i

npm run build

npm test

Then you can see the result of test cases.

4. License

ISC@ProtoTeam.

tcharts.js's People

Contributors

hustcc avatar ziqiangwang avatar pandorym avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.