Skip to main content

Stdlib-only text visualizations — sparklines, mini bar charts, heatmaps.

Project description

codechu-spark

   ___          _           _
  / __\___   __| | ___  ___| |__  _   _
 / /  / _ \ / _\` |/ _ \/ __| '_ \| | | |
/ /__| (_) | (_| |  __/ (__| | | | |_| |
\____/\___/ \__,_|\___|\___|_| |_|\__,_|

Stdlib-only text visualizations — Unicode sparklines, labeled mini bar charts, 1D heatmaps — extracted from the Disk Cleaner toolchain. No external dependencies. Python 3.10+.

Install

pip install codechu-spark

API

sparkline(values, *, width=None, chars="▁▂▃▄▅▆▇█")

from codechu_spark import sparkline

sparkline([1, 3, 7, 2, 5])                # → '▁▃█▂▅'
sparkline(list(range(100)), width=10)     # downsampled by averaging
sparkline([1, 2, 3], chars=".-=#")        # custom glyphs
  • width=None → one glyph per value
  • width<len(values) → downsample by averaging consecutive buckets
  • width>len(values) → render at len(values) (no upsampling)
  • Empty list → ''; all-equal → first glyph repeated

bar_chart(items, *, width=40, char="█")

from codechu_spark import bar_chart

print(bar_chart([
    ("python", 42),
    ("rust",   17),
    ("go",     8),
], width=20))
# python  ████████████████████  42
# rust    ████████              17
# go      ███                    8

Bars are scaled to the maximum value. Labels are left-aligned to the longest label. Negative values clip to a zero-width bar.

heatmap(values, *, chars=" ░▒▓█")

from codechu_spark import heatmap

heatmap([0, 1, 2, 3, 4])     # → ' ░▒▓█'
heatmap([0, 5, 10], chars=".oO")

A denser-than-sparkline row. Useful for per-bucket load, hour-of-day utilization, or any single-row intensity readout.

Design

  • Pure stdlib. Zero third-party dependencies.
  • Single-row primitives. Each function returns a string (with embedded newlines for bar_chart); no terminal control codes, no cursor movement — that's a separate concern.
  • Custom glyphs welcome. Pass any chars string ordered low → high.

Tests

pip install -e ".[dev]"
pytest -q

Coverage gate: ≥90 %.

License

MIT — see LICENSE.

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

codechu_spark-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codechu_spark-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file codechu_spark-0.1.0.tar.gz.

File metadata

  • Download URL: codechu_spark-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codechu_spark-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44bb1436aed6f63545ced3eb220335729cf1efa6872d0c491b259431731e6b4a
MD5 577fb486894c69086a42201cd7452385
BLAKE2b-256 730ef5d4e316fcf00f48084ed9b86050343b2fce64557993ef7abd91aa90b307

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_spark-0.1.0.tar.gz:

Publisher: release.yml on codechu/spark-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codechu_spark-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codechu_spark-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codechu_spark-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 092c0162ef4ec756576c49304f65bf5cfee5e367e0c5e8ab145cb2245f5b262f
MD5 4e3b56bf6f28de37ee7b1baae13b0769
BLAKE2b-256 c5dc41bbd3e88186ec69643275cf05b1305a0d38846b128bbcec9e635db5e119

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_spark-0.1.0-py3-none-any.whl:

Publisher: release.yml on codechu/spark-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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