-
Notifications
You must be signed in to change notification settings - Fork 1
/
graphics.js
66 lines (58 loc) · 1.64 KB
/
graphics.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var args = process.argv.slice(2);
var blessed = require('blessed');
var contrib = require('blessed-contrib');
var screen = blessed.screen();
var grid = new contrib.grid({rows: 12, cols: 12, screen: screen});
var line = null;
var logger = grid.set(0, 8, 8, 4, contrib.log, {
fg: "green",
selectedFg: "green",
label: 'Server Log'
});
var table = grid.set(8,8,4,4, contrib.table, {
keys: true,
fg: 'white',
selectedFg: 'white',
selectedBg: 'blue',
interactive: true,
label: 'Stats',
border: {type: "line", fg: "cyan"},
columnSpacing: 10,
columnWidth: [12, 12]
});
module.exports.render = function render() {
screen.render();
}
module.exports.setup = function setup() {
line = grid.set(0, 0, 12, 8, contrib.line, {
width: 80,
height: 30,
numYLabels: 10,
style: {
line: "yellow",
text: "green",
baseline: "black"
},
xLabelPadding: 2,
xPadding: 5,
label: 'Price',
minY: (global.session.config.currencies.buy_at - (global.session.config.currencies.buy_at * 0.01)) * global.session.config.currencies.multiplier,
maxY: (global.session.config.currencies.sell_at + (global.session.config.currencies.sell_at * 0.01)) * global.session.config.currencies.multiplier
});
screen.append(line);
screen.append(logger);
screen.append(table);
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
screen.render();
}
module.exports.updatePrices = function updatePrices(data) {
line.setData(data);
}
module.exports.updateStats = function updateStats(data) {
table.setData(data);
}
module.exports.log = function log(string) {
logger.log(string);
}