kroitor / asciichart

Nice-looking lightweight console ASCII line charts ╭┈╯ for NodeJS, browsers and terminal, no dependencies
MIT License
1.84k stars 94 forks source link

Add support for multiple data series in Python version #46

Closed jwbensley closed 4 years ago

jwbensley commented 4 years ago

This pull request adds support for multiple data series in the Python version, which is currently missing but is present in the JS version.

This is the test script I'm using:

(asciichart)$cat jb.py 

#!/usr/bin/env python3

import asciichartpy
import random
from time import sleep

InMbps = [random.randint(-100, 0) for x in range(1, 60)]
OutMbps = [random.randint(100, 200) for x in range(1, 60)]

while True:

    print("\033[H\033[J", end='') # clear screen

    config = {
        "height": 20,
    }

    for i in range(0, len(InMbps)-1):
        InMbps[i] = InMbps[i+1]
    InMbps[-1] = random.randint(-100, 0)

    for i in range(0, len(OutMbps)-1):
        OutMbps[i] = OutMbps[i+1]
    OutMbps[-1] = random.randint(100, 200)

    print(asciichartpy.plot([InMbps, OutMbps], config))
    sleep(1)

Output can be seen here to prove it's working: https://i.imgur.com/97hPiq9.png

Also running the test script test.py works as expected, as can be seen here: https://i.imgur.com/B9252nB.png

kroitor commented 4 years ago

Thank you so much! I will test on my side and will merge asap!

jwbensley commented 4 years ago

Hi @kroitor I didn't meant to include the commit which includes the support for coloured graphs, it's not finished yet, I will make a new pull request without this.

kroitor commented 4 years ago

hi @jwbensley! Awesome, appreciate your involvement!