Personal Chart

Run Settings
LanguagePython
Language Version
Run Command
def chart(lines): tmp = [] mx = 0 MW = 30 LJ = len(max((line.replace('\t', ' ').rsplit(' ', 1)[0] for line in lines.splitlines() if line.strip()), key=len)) for line in lines.splitlines(): if not line.strip(): continue name, change = line.replace('\t', ' ').rsplit(' ', 1) change = int(change) c = change // 3 if change > 0: bar = '{} {}{} {}%'.format(name.ljust(LJ), "‒" * max(1, min(c, MW)), '...' if change > MW else '', change) else: bar = '{}% {}{} {}'.format(change, '...' if abs(change) > MW else '', '‒' * max(1, min(abs(c), MW)), name) if len(bar) > mx: mx = len(bar) tmp.append(bar) for line in tmp: if not line.startswith('-'): print(' ' * mx, line) else: print(' ' * (mx - len(line)), line) if __name__ == '__main__': chart(''' Happiness 15 Reading -90 Writing 20 Risk-taking -10 Socializing 35 Trust 19 Effectivity 60 Cruelty 5 Friendliness 30 Health 33 Sentimentality -33 Diversity 40 Curiosity -7 Sanity 23 Finance 199 Freedom 160 Punctuality 20 Helpfulness -15 Craziness 7 Doing 80 Logic 2 Wisdom 1 Sense of Adventure -15 Determinedness 80 Sense of Humor 6 ''')
Editor Settings
Theme
Key bindings
Full width
Lines