kroitor / asciichart

Nice-looking lightweight console ASCII line charts ╭┈╯ for NodeJS, browsers and terminal, no dependencies
MIT License
1.87k stars 94 forks source link

broken chart with a big array #36

Closed jjalonso closed 4 years ago

jjalonso commented 4 years ago

Im testing ascii chart with some long data array and when I console.log on terminal everything get broken, it doesnt look good

[ 968, 969, 968, 967, 967, 967, 967, 966, 966, 964, 964, 966, ... 21499 more items ]

Basically it start printing a lot of lines, this screenshot its only a snapshot of the long print Screenshot 2019-11-13 at 15 25 58

The code im using is this. and the array result is the printed above.

const data = require('../data/1m/bitmex_BTCUSD_1m-15d.json');
const pricesData = data.map(tick => Math.round(tick.close));
console.log (asciichart.plot(pricesData));
kroitor commented 4 years ago

As described in the README.md for this package, the length of the chart will always be equal to the length of your data series. With the smallest fonts in the terminal you probably have 100-200 characters of width at most inside your terminal screen. Therefore you should not attempt to draw long sequences with this package. Or, you simply do data.slice (-your_max_term_width) before rendering to draw just the last portion of the graph that fits into your terminal window. Hope that answers the question.