How to use the termgraph.termgraph.chart function in termgraph

To help you get started, we’ve selected a few termgraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkaz / termgraph / tests / test_termgraph.py View on Github external
def test_chart_multiple_series_no_colors_prints_correctly(self):
        with patch('sys.stdout', new=StringIO()) as output:
            colors = []
            data = [[183.32, 190.52], [231.23, 5.0], [16.43, 53.1], [50.21, 7.0],
                    [508.97, 10.45], [212.05, 20.2], [30.0, 20.0]]
            args = {'filename': 'data/ex4.dat', 'title': None, 'width': 50,
                    'format': '{:<5.2f}', 'suffix': '', 'no_labels': False,
                    'color': None, 'vertical': False, 'stacked': False,
                    'different_scale': False, 'calendar': False,
                    'start_dt': None, 'custom_tick': '', 'delim': '',
                    'verbose': False, 'version': False}
            labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014']
            tg.chart(colors, data, args, labels)
            output = output.getvalue().strip()
            assert output == '2007: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 183.32\n      ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 190.52\n2008: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 231.23\n      ▇ 5.00 \n2009: ▇▇▇▇ 16.43\n      ▇▇▇▇▇▇▇▇▇▇▇▇▇ 53.10\n2010: ▇▇▇▇▇▇▇▇▇▇▇▇▇ 50.21\n      ▇ 7.00 \n2011: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 508.97\n      ▇▇ 10.45\n2012: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 212.05\n      ▇▇▇▇▇ 20.20\n2014: ▇▇▇▇▇▇▇ 30.00\n      ▇▇▇▇▇ 20.00'
github mkaz / termgraph / tests / test_termgraph.py View on Github external
def test_chart_stacked_prints_correctly(self):
        with patch('sys.stdout', new=StringIO()) as output:
            colors = [91, 94]
            data = [[183.32, 190.52], [231.23, 5.0], [16.43, 53.1], [50.21, 7.0],
                    [508.97, 10.45], [212.05, 20.2], [30.0, 20.0]]
            args = {'filename': 'data/ex4.dat', 'title': None, 'width': 50,
                    'format': '{:<5.2f}', 'suffix': '', 'no_labels': False,
                    'color': None, 'vertical': False, 'stacked': True,
                    'different_scale': False, 'calendar': False,
                    'start_dt': None, 'custom_tick': '', 'delim': '',
                    'verbose': False, 'version': False}
            labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014']
            tg.chart(colors, data, args, labels)
            output = output.getvalue().strip()
            assert output == '2007: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 373.84\n2008: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇\x1b[0m 236.23\n2009: \x1b[91m▇▇▇▇\x1b[0m\x1b[94m▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 69.53\n2010: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇\x1b[0m 57.21\n2011: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇▇\x1b[0m 519.42\n2012: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇▇▇▇▇\x1b[0m 232.25\n2014: \x1b[91m▇▇▇▇▇▇▇\x1b[0m\x1b[94m▇▇▇▇▇\x1b[0m 50.00'
github mkaz / termgraph / tests / test_termgraph.py View on Github external
def test_chart_multiple_series_prints_correctly(self):
        with patch('sys.stdout', new=StringIO()) as output:
            colors = [91, 94]
            data = [[183.32, 190.52], [231.23, 5.0], [16.43, 53.1], [50.21, 7.0],
                    [508.97, 10.45], [212.05, 20.2], [30.0, 20.0]]
            args = {'filename': 'data/ex4.dat', 'title': None, 'width': 50,
                    'format': '{:<5.2f}', 'suffix': '', 'no_labels': False,
                    'color': None, 'vertical': False, 'stacked': False,
                    'different_scale': False, 'calendar': False,
                    'start_dt': None, 'custom_tick': '', 'delim': '',
                    'verbose': False, 'version': False}
            labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014']
            tg.chart(colors, data, args, labels)
            output = output.getvalue().strip()
            assert output == '2007: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 183.32\n      \x1b[94m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 190.52\n2008: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 231.23\n      \x1b[94m▇\x1b[0m 5.00 \n2009: \x1b[91m▇▇▇▇\x1b[0m 16.43\n      \x1b[94m▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 53.10\n2010: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 50.21\n      \x1b[94m▇\x1b[0m 7.00 \n2011: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 508.97\n      \x1b[94m▇▇\x1b[0m 10.45\n2012: \x1b[91m▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\x1b[0m 212.05\n      \x1b[94m▇▇▇▇▇\x1b[0m 20.20\n2014: \x1b[91m▇▇▇▇▇▇▇\x1b[0m 30.00\n      \x1b[94m▇▇▇▇▇\x1b[0m 20.00'
github mkaz / termgraph / tests / test_termgraph.py View on Github external
def test_chart_prints_correct_chart(self):
        with patch('sys.stdout', new=StringIO()) as output:
            colors = []
            data = [[183.32], [231.23], [16.43], [50.21], [508.97],
                    [212.05], [1.0]]
            args = {'filename': 'data/ex1.dat', 'title': None, 'width': 50,
                    'format': '{:<5.2f}', 'suffix': '', 'no_labels': False,
                    'color': None, 'vertical': False, 'stacked': False,
                    'different_scale': False, 'calendar': False,
                    'start_dt': None, 'custom_tick': '', 'delim': '',
                    'verbose': False, 'version': False}
            labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014']
            tg.chart(colors, data, args, labels)
            output = output.getvalue().strip()
            assert output == '2007: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 183.32\n2008: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 231.23\n2009: ▇ 16.43\n2010: ▇▇▇▇ 50.21\n2011: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 508.97\n2012: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 212.05\n2014: ▏ 1.00'
github mkaz / termgraph / tests / test_termgraph.py View on Github external
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'