Skip to main content

Library to print piecharts in your terminal

Project description

Term-Piechart

Tests codecov PyPI - Python Version

Displays pie charts in your terminal. This is a direct python rewrite of the Ruby Gem TTY-Pie. Maybe someone else would find this usefull as well. It requires no external dependencies and supports ASCII and HEX color codes as well as automatic generation of random colors.

Installation

python -m pip install term-piechart

Examples

from term_piechart import Pie

requests = [
    {"name": "GET", "value": 9983},
    {"name": "POST", "value": 7005},
    {"name": "DELETE", "value": 3323},
    {"name": "PUT", "value": 2794},
    {"name": "PATCH", "value": 1711},
]

pie = Pie(
    requests,
    radius=5,
    autocolor=True,
    autocolor_pastel_factor=0.7,
    legend={"line": 0, "format": "{label} {name:<8} {percent:>5.2f}% [{value}]"},
)

More in examples

Class Arguments:

  • data (default: []): A list of dicts with following elements representing the slices
    • name: Name of the element
    • value: Value of the element
    • fill (default: ): String to fill the slice with
    • color: Hexcode or ANSII Colorname
  • radius (default: 10): Amount of columns/rows as the radius to change size
  • autocolor (default: False): Can be enabled if there are no colors specified in the data dict
  • autocolor_pastel_factor (default: 0): Can be increased until 1
  • fill (default: ): Overwrite the fill symboll for every element
  • legend (default: True): Can be disabled via False or configured with a dict with those keys:
    • line (default: 1): Number of lines between legend elements
    • left (default: 4): Number of spaces between chart and left of legend
    • format (default: {label} {name} {percent:.2f}): Supports {value} as well
  • aspect_ratio (default: 2): Aspect ratio of the printed chart
  • top (default: None): Amount of rows from top of the visible terminal
  • left (default: None): Amount of columns from the left of the visible terminal

References

term-piechart is a direct python derivate of:

Developement

Tox

There's a minimal tox.ini with a requirement on pyenv and un-def/tox-pyenv-redux. Zsh users can use this as a reference.

curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
. ~/.zshrc
pyenv install -s 3.12 3.11 3.10 3.9 3.8
tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

term_piechart-0.1.2.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

term_piechart-0.1.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file term_piechart-0.1.2.tar.gz.

File metadata

  • Download URL: term_piechart-0.1.2.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for term_piechart-0.1.2.tar.gz
Algorithm Hash digest
SHA256 127ef497dcfa60054e07d408c660c6cf6e737b1469aaac2fcda56ffc66a4e682
MD5 4290cf0ff2c7dee8c4bdde8987e54938
BLAKE2b-256 f7dd9685261230e58c7c1baf8ad53c24624b13a745aa343dacebab3be53e85d4

See more details on using hashes here.

File details

Details for the file term_piechart-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for term_piechart-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d57ef6363ecb956b4864b095ee763cfdbadbbe317fb8beafed68a1fc5b1705a
MD5 20433a2e2d5064f1a80b7c66c3717a84
BLAKE2b-256 b3756bfb4c4bc80aacc56c52271bbce5292d409c8124a4163f76993b7eecb850

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page