Repository: mkaz/termgraph

Issue:
Bad display with --stacked
The display in column doesn't work properly with the --stacked option.

```
Example1: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 22.00
Longertext example : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 36.00
```

I have to use `column -t -s ':'` to clean it up.

Comments:

Patch:
diff --git a/setup.py b/setup.py
index 7b9e577..69f91a8 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ setup(
     name='termgraph',
     packages=['termgraph'],
     entry_points={'console_scripts': ['termgraph=termgraph.termgraph:main']},
-    version='0.1.4',
+    version='0.1.5',
     author="mkaz",
     author_email="marcus@mkaz.com",
     url='https://github.com/mkaz/termgraph',
@@ -28,6 +28,7 @@ setup(
     description='a python command-line tool which draws basic graphs in the terminal',
     platforms='any',
     keywords='python CLI tool drawing graphs shell terminal',
+    python_requires='>=3.6',
     install_requires=['colorama'],
     classifiers=[
         'Development Status :: 5 - Production/Stable',
diff --git a/termgraph/termgraph.py b/termgraph/termgraph.py
index 520a12a..ae3a90e 100755
--- a/termgraph/termgraph.py
+++ b/termgraph/termgraph.py
@@ -13,7 +13,7 @@ from itertools import zip_longest
 from colorama import init
 
 
-VERSION = '0.1.4'
+VERSION = '0.1.5'
 
 init()
 
@@ -267,7 +267,8 @@ def stacked_graph(labels, data, normal_data, len_categories, args, colors):
             # Hide the labels.
             label = ''
         else:
-            label = "{}: ".format(labels[i])
+            label = "{:<{x}}: ".format(labels[i],
+                                       x=find_max_label_length(labels))
 
         print(label, end="")
         values = data[i]


Test patch:
diff --git a/tests/test_termgraph.py b/tests/test_termgraph.py
index 441c0a5..aef7b4c 100644
--- a/tests/test_termgraph.py
+++ b/tests/test_termgraph.py
@@ -168,6 +168,24 @@ class TermgraphTest(unittest.TestCase):
             output = output.getvalue().strip()
             assert output == '2007: [91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇[0m[94m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇[0m 373.84\n2008: [91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇[0m[94m▏[0m 236.23\n2009: [91m▇▇▇[0m[94m▇▇▇▇▇▇▇▇▇▇▇▇[0m 69.53\n2010: [91m▇▇▇▇▇▇▇▇▇▇▇▇[0m[94m▏[0m 57.21\n2011: [91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇[0m[94m▇[0m 519.42\n2012: [91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇[0m[94m▇▇▇▇[0m 232.25\n2014: [91m▇▇▇▇▇▇[0m[94m▇▇▇▇[0m 50.00'
 
+    def test_stacked_graph_different_label_length_prints_correct_graph(self):
+        with patch('sys.stdout', new=StringIO()) as output:
+            labels = ['LOOOOOOOOOOOOOOOOOOOOOOOOONG LINE', 'SHORT LINE']
+            data = [[10.0, 20.0], [10.0, 20.0]]
+            normal_data = [[10.0, 20.0], [10.0, 20.0]]
+            len_categories = 2
+            args = {'filename': '-', 'title': 'BEAUTIFUL', 'width': 50,
+                    'format': '{:<5.2f}', 'suffix': '',
+                    'no_labels': False, 'color': ['blue', 'red'],
+                    'vertical': False, 'stacked': True,
+                    'different_scale': False, 'calendar': False,
+                    'start_dt': None, 'custom_tick': '', 'delim': '',
+                    'verbose': False, 'version': False}
+            colors = [94, 91]
+            tg.chart(colors, data, args, labels)
+            output = output.getvalue().strip()
+            assert output == 'LOOOOOOOOOOOOOOOOOOOOOOOOONG LINE: \x1b[94m▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 30.00\nSHORT LINE                       : \x1b[94m▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 30.00'
+
     def test_stacked_graph_no_label_prints_no_labels(self):
         with patch('sys.stdout', new=StringIO()) as output:
             labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014']