kroitor / asciichart

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

Add support for multiple data series in Python version (v2) #47

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

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 99.048% when pulling 4be34b7ac4d85cabd1a904ee755901d37af580ed on jwbensley:multi_series into cc5ddc62d3a1c7995e2c5a8950f30360582eefca on kroitor:master.

jwbensley commented 4 years ago

Hi @kroitor that is the multi-series pull request fixed. This is to align the python version to the JS version, the JS version already has multi series support but I'm using the Python version. The JS version also has support for colours. I have another pull request ready to make to add colours to the Python version. Are you interested in the colours in the Python version, shall I make that pull request?

kroitor commented 4 years ago

@jwbensley thx again for your help! I will need a bit of time to test it on my side and merge.

Are you interested in the colours in the Python version, shall I make that pull request?

Yep, sure, that would be great. However, it would be a little bit easier for me to handle the enhancements one by one. I'd suggest that we merge this PR first, and then add colors afterwards, based on the merged repo.

jwbensley commented 4 years ago

Sure - understood, I'll await further instruction from you. Thank you!

kroitor commented 4 years ago

@jwbensley pardon for the delay on my side – I'm a bit overloaded with work atm, but will do my best to get to it asap. Thx for your patience!

jwbensley commented 4 years ago

No worries @kroitor - I have the 2nd pull request ready to add colour support too, when you are ready.