Skip to main content

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

Project description

   c o d e c h u  ·  s p a r k
   ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁▂▄▆█▆▄▂▁▃▅▇█▇▅▃▁▂▅█▅▂▁▄▇▄▁▂▆█▆▂▁▃▇▇▃▁
   ── one line. one glance. one truth about your data. ──

Unicode sparklines, mini bar charts, and 1-D heatmaps — pure text.

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.2.0.tar.gz (7.5 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.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codechu_spark-0.2.0.tar.gz
  • Upload date:
  • Size: 7.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 06d341c50c2706c2c856e4481ffaa1a627e3c419f6dd580f278c57e7a1cc9294
MD5 af2c87c6b44a43ab1780f95a4f138461
BLAKE2b-256 db3d3351110c22c7d13ff2d83fe55c2982de6476099afe114fab8bee8a3d4765

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_spark-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: codechu_spark-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9c4e37acd491a2ef2cefca53b5e37a30ca4d95df837ced07a274bc8f97e079e
MD5 c35f79b240325b1367144c2c7120683d
BLAKE2b-256 34bce9d1000e7e7f83aa3b54191e0f6610d182ab461ab37c926d70bab5e39c54

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_spark-0.2.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