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

Python Improvements: Add support for NaNs, fix min/max behavior, and more docs #38

Closed pkazmier closed 4 years ago

pkazmier commented 4 years ago

Data series may now contain NaNs. NaN values will insert a space in the chart to indicate missing data:

>>> series = [1,2,3,4,float("nan"),4,3,2,1]
>>> print(asciichartpy.plot(series))
4.00  ┤  ╭╴╶╮
3.00  ┤ ╭╯  ╰╮
2.00  ┤╭╯    ╰╮
1.00  ┼╯      ╰

Fix a bug if data values exceeded user-defined minimum and maximum values. The prior version failed to clamp the values, so the following would not be possible:

>>> series = [1,2,3,4,float("nan"),4,3,2,1]
>>> print(asciichartpy.plot(series, {'minimum': 2, 'maximum': 3}))
3.00  ┤ ╭─╴╶─╮
2.00  ┼─╯    ╰─

Improve the API documentation by adding a module docstring as well as adding several examples to the plot docstring.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 0561347529e5192b5e0999fba62f4f0ae0587dec on pkazmier:master into 2bfa94bb795f595e14bcd8e9e4ed3a9781b6291b on kroitor:master.

pkazmier commented 4 years ago

I've been using asciicharts to plot time series data, so it is important that the the library can handle missing data as the data sets I'm using sometimes contain missing data. This PR adds support for that to the Python version.

kroitor commented 4 years ago

Hi @pkazmier ! Thank you so much for the PR! I will do my best to test it, merge and update package versions asap.