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.

Documentation

  • API reference — every public symbol with signatures, examples, and edge-case tables.
  • Recipes — sparkline windows, top-N bars, 1-D heatmaps, custom ramps, terminal-width downsampling.
  • Migration guide — 0.1 → 0.2 (internal refactor, no API changes).

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: codechu_spark-0.3.0.tar.gz
  • Upload date:
  • Size: 11.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 fe28fb95a7a4d5a0bd073bac25a9c80b3932283ef65e2528479adcbced9c9f4a
MD5 e60987e7381b101ddb679db12e4383e7
BLAKE2b-256 3f1c3609cd3c3b670ffa83a45936c3adecf50285a0bbed0ef1c0aa64c8c76e54

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: codechu_spark-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14b298b9a5289295417e3ddd4c2b0e1d7b9a0e530f39e60f52d7286c62106c3d
MD5 0dd4e302cbaac7c5df20d40d0d7f004c
BLAKE2b-256 21db56cc661dbeee660cdbd0894cdb215a6bc0d2b79d726af5361ae1897e4fa0

See more details on using hashes here.

Provenance

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