mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal
MIT License
3.14k stars 165 forks source link

Adding three small features #65

Open moravveji opened 4 years ago

moravveji commented 4 years ago

Hi.

I would like to propose three small modifications, in order to address the issue https://github.com/mkaz/termgraph/issues/60.

The major change is that now, the normalize() function basically uses the sum of each row of values in data, instead of the max_dat. This protects the case where max_dat < width against bad bar plots.

I also changed int() to round() to make sure that the bars (almost) add up to 100 when the data is expressed in percentage. Otherwise, the bars would not line up nicely.

Please let me know what you think of the changes.

Kind regards Ehsan

mkaz commented 4 years ago

Thanks for the contribution!

I updated recently in 0.4.2 to fix the issue with max < width, do you think this change is still necessary?

The int() to round() seems like a good change.

It is difficult to see your change with all of the linting changes, can you setup black formatter and run that on your change first, it should auto format and match the style of mine.

Installation: python -m pip install black Run: black termgraph/termgraphy.py Or run as a module if the above doesn't work: python -m black termgraph/termgraphy.py

You can also setup your Editor to auto format, instructions here, depends on what editor you use.