Skip to content

Commit 3698ef3

Browse files
authored
Merge pull request #28 from crudson/fix-graph-yaxis
Fix graph yaxis
2 parents 8b25a5f + 2203ad0 commit 3698ef3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/cli/chart.js

Lines changed: 5 additions & 3 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
};
911
chartData = Object.values(data.timeline[type]).flat();
1012
return chart.plot(chartData, config);
11-
}
13+
}

0 commit comments

Comments
 (0)