nschloe / termplotlib

:chart_with_upwards_trend: Plotting on the command line
GNU General Public License v3.0
675 stars 19 forks source link

barh() all zero vals results in ZeroDivisionError #69

Closed jeppenodgaard closed 3 years ago

jeppenodgaard commented 3 years ago
import termplotlib
fig = termplotlib.figure()
fig.barh([0, 0], ['Eggs', 'Dogs'])

Results in

  File "/home/jo/.local/lib/python3.9/site-packages/termplotlib/figure.py", line 62, in barh
    self._content.append(barh(*args, **kwargs))
  File "/home/jo/.local/lib/python3.9/site-packages/termplotlib/barh.py", line 25, in barh
    matrix = _get_matrix_of_eighths(vals, max_width, bar_width)
  File "/home/jo/.local/lib/python3.9/site-packages/termplotlib/barh.py", line 76, in _get_matrix_of_eighths
    eighths = [int(round(count / max_count * max_size * 8)) for count in counts]
  File "/home/jo/.local/lib/python3.9/site-packages/termplotlib/barh.py", line 76, in <listcomp>
    eighths = [int(round(count / max_count * max_size * 8)) for count in counts]
ZeroDivisionError: division by zero

Process finished with exit code 1