C-chart
A library to draw chart in command line
_ _ _ _
/ \ | | (_) | |__ _ __ __ _ _ __ _ _
/ _ \ | | | | | '_ \ | '__| / _` | | '__| | | | |
/ ___ \ | | | | | |_) | | | | (_| | | | | |_| |
/_/ \_\ |_| |_| |_.__/ |_| \__,_| |_| \__, |
_ _ |___/ _ _
| |_ ___ __| | _ __ __ _ __ __ ___ | |__ __ _ _ __ | |_
| __| / _ \ / _` | | '__| / _` | \ \ /\ / / / __| | '_ \ / _` | | '__| | __|
| |_ | (_) | | (_| | | | | (_| | \ V V / | (__ | | | | | (_| | | | | |_
\__| \___/ \__,_| |_| \__,_| \_/\_/ \___| |_| |_| \__,_| |_| _ \__|
(_) _ __ ___ ___ _ __ ___ _ __ ___ __ _ _ __ __| | | | (_) _ __ ___
| | | '_ \ / __| / _ \ | '_ ` _ \ | '_ ` _ \ / _` | | '_ \ / _` | | | | | | '_ \ / _ \
| | | | | | | (__ | (_) | | | | | | | | | | | | | | (_| | | | | | | (_| | | | | | | | | | | __/
|_| |_| |_| \___| \___/ |_| |_| |_| |_| |_| |_| \__,_| |_| |_| \__,_| |_| |_| |_| |_| \___|
Install
npm i c-chart
Current support chart:
- bar
- scatter
Bar
import print from "c-chart";
print({
type: "bar",
data: [5, 7, 3, 2],
direction: "y"
});
↑ _
| | |
| | |
| _ | |
| | | | |
| | | | |
| | | | | _
| | | | | | | _
| | | | | | | | |
+-------+------+------+------+---------→
Or you can change the direction by direction: 'x'
import print from "c-chart";
print({
type: "bar",
data: [5, 7, 3, 2]
});
+--------------------------------------→
|
|_______________________
|_______________________|
|______________________________________
|______________________________________|
|________
|________|
|_
|_|
|
|
|
↓
Scatter
import print from ".";
print({
type: "scatter",
data: [
[10.0, 8.04],
[8.07, 6.95],
[13.0, 7.58],
[9.05, 8.81],
[11.0, 8.33],
[14.0, 7.66],
[13.4, 6.81],
[10.0, 6.33],
[14.0, 8.96],
[12.5, 6.82],
[9.15, 7.2],
[11.5, 7.2],
[3.03, 4.23],
[12.2, 7.83],
[2.02, 4.47],
[1.05, 3.33],
[4.05, 4.96],
[6.03, 7.24],
[12.0, 6.26],
[12.0, 8.84],
[7.08, 5.82],
[5.02, 5.68]
]
});
↑
| * * *
| * *
| * * * *
| * * * * *
| * * *
| *
| * *
| *
+*-------------------------------------→