mkaz / termgraph

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

Vertical graph not rendering? #76

Open ckcollab opened 3 years ago

ckcollab commented 3 years ago

First of all: thank you so much for this neat library, appreciate all the work that has gone into making this :)

I am trying to make a graph from within another Python script, and here's a working version:

In [1]: from termgraph.termgraph import stacked_graph, AVAILABLE_COLORS, normalize, chart
   ...: 
   ...: labels = ["size 1", "size 10", "size 100"]
   ...: data = [
   ...:     [1, 1, 10],
   ...:     [1, 10, 100],
   ...:     [1, 100, 120],
   ...: ]
   ...: colors = [
   ...:     AVAILABLE_COLORS.get("green"),
   ...:     AVAILABLE_COLORS.get("yellow"),
   ...:     AVAILABLE_COLORS.get("red"),
   ...: ]
   ...: args = {
   ...:     "no_labels": False,
   ...:     "format": "{:<5.2f}",
   ...:     "suffix": "",
   ...:     "stacked": False,
   ...:     "histogram": False,
   ...:     "width": 50,
   ...:     "different_scale": False,
   ...:     "no_values": False,
   ...:     "vertical": False,
   ...: }
   ...: chart(colors, data, args, labels)
size 1  : ▏ 1.00 
          ▏ 1.00 
          ▇▇▇▇ 10.00
size 10 : ▏ 1.00 
          ▇▇▇▇ 10.00
          ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
size 100: ▏ 1.00 
          ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
          ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 120.00

However, if I change args["vertical"] to True, I get ...

In [2]: args["vertical"] = True
   ...: chart(colors, data, args, labels)
   ...: 

(no output)

Maybe I am switching up args weirdly or something, looked through the Readme and I may have missed any misc. requirements for vertical. Appreciate any help, will keep digging though!

EDIT

Of course as soon as I post this I find...

https://github.com/mkaz/termgraph/blob/main/termgraph/termgraph.py#L465

Adding "different_scale": True, made something print, but it seems rather broken.