kroitor / asciichart

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

Max/min values not reached #25

Open neighthan opened 5 years ago

neighthan commented 5 years ago

Depending on the height set for a chart (even if the y-axis labels are exactly the same), the appropriate values are not always reached (at least when these are the max / min values; I haven't tested enough to check others yet). E.g., using the Python version, everything looks fine in this first plot:

$ pplot 1 10 --height 9
   10.00  ┤╭ 
    9.00  ┤│ 
    8.00  ┤│ 
    7.00  ┤│ 
    6.00  ┤│ 
    5.00  ┤│ 
    4.00  ┤│ 
    3.00  ┤│ 
    2.00  ┤│ 
    1.00  ┼╯ 

but if we change the height to 8, even though we still achieve exactly the first and last values on the y-axis, it's shown that the first point is 2 instead of 1:

$ pplot 1 10 --height 8
   10.00  ┼╭ 
    9.00  ┤│ 
    8.00  ┤│ 
    7.00  ┤│ 
    6.00  ┤│ 
    5.00  ┤│ 
    4.00  ┤│ 
    3.00  ┤│ 
    2.00  ┤╯ 
    1.00  ┼  

If we increase the height, then we don't reach the max value anymore:

$ pplot 1 10 --height 10
   10.00  ┤  
    9.18  ┤╭ 
    8.36  ┤│ 
    7.55  ┤│ 
    6.73  ┤│ 
    5.91  ┤│ 
    5.09  ┤│ 
    4.27  ┤│ 
    3.45  ┤│ 
    2.64  ┤│ 
    1.82  ┤│ 
    1.00  ┼╯