Skip to content

Commit 650de50

Browse files
committed
Fixed graph yaxis padding. Minor typo in comment in same file.
1 parent 0edb8c8 commit 650de50

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/cli/chart.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
const chart = require('asciichart');
22

3-
// generate chart for caes or deaths
3+
// generate chart for cases or deaths
44
exports.generate = (data, type = 'cases') => {
5+
const maxLength = Object.values(data.timeline[type])
6+
.reduce((a,c) => Math.max(a, c.toFixed().length), 0)
57
const config = {
68
height: 7,
7-
format: (x, i) => (' ' + x.toFixed(0)).slice(-' '.length)
9+
format: (x, i) => x.toFixed().padStart(maxLength)
810
};
9-
chartData = Object.values(data.timeline[type]).flat();
11+
chartData = Object.values(data.timeline[type]);
1012
return chart.plot(chartData, config);
11-
}
13+
}

0 commit comments

Comments
 (0)